大佬教程收集整理的这篇文章主要介绍了php 标头(位置:)不会重定向,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在写一个注册页面。检查凭据并将记录插入数据库后,注册页面将被重定向到注册成功页面,该页面将列出您的 user_ID 并允许您使用该 user_ID 登录登录页面。当我第一次编写代码时,下面的代码运行良好。但是,最近几天,当我再次执行它时,它不会重定向到注册成功页面而是登录页面。这很奇怪,因为我没有写header(位置:login.PHP)。我已经尝试了 stackoverflow 中的大部分建议,但仍然无法奏效。
我的 register.PHP 代码
session_start();
include("connection.PHP");
include("functions.PHP");
$message = "";
if ($_SERVER['REQUEST_METHOD'] == "POST")
{
//something was posted
$user_name = MysqLi_real_escape_string($connection,strip_Tags($_POST['user_name']));
$email = MysqLi_real_escape_string($connection,strip_Tags($_POST['email']));
$password = MysqLi_real_escape_string($connection,strip_Tags($_POST['password']));
$password2 = MysqLi_real_escape_string($connection,strip_Tags($_POST['password2']));
$h_password = "";
$message = "";
if (valID_email($email))
{
if ($password != $password2)
{
$message = "The passwords you entered do not match - please go back and try again.";
} else
{
if ((strlen($password) < 8) ||(strlen($password) > 16))
{
$message = "Your password must between 8 to 16 characters Please go back and try again.";
} else
{
//save to database
$user_ID = random_num(10);
$user_image = 'assets/images/profile.jpg';
$h_password = md5($password);
$query = "INSERT INTO users (user_ID,user_name,password,email,user_image) VALUES ('$user_ID','$user_name','$h_password','$email','$user_image')";
$res = MysqLi_query($connection,$query);
header("Location: success.PHP?user_ID=$user_ID");
dIE;
}
}
} else
{
$message= "That is not a valID email address. Please go back and try again.";
}
}
我的success.PHP代码
<?PHP
session_start();
include("connection.PHP");
include("functions.PHP");
$user_data = check_login($connection);
$user_ID = $_GET['user_ID'];
$q = "SELECT user_ID from users where user_ID = '$user_ID'";
$e = MysqLi_query($connection,$q);
$f = MysqLi_fetch_assoc($e);
?>
<HTML lang="en">
<head>
<Meta charset="utf-8">
<Meta name="vIEwport" content="wIDth=device-wIDth,initial-scale=1">
<link rel="stylesheet" href="assets/stylesheets/loginNsignup.CSS" type="text/CSS">
<Title>Registration Successful!</Title>
</head>
<body>
<h1>Congrats! Your registration is successful! Now you can login!</h1>
<p>Your user_ID is <?PHP echo ' ' . $f['user_ID'] ?></p>
<div><a href="login.PHP" class="btn" style="border-radius:50%;">Login</a></div>
</body>
</HTML>
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)
以上是大佬教程为你收集整理的php 标头(位置:)不会重定向全部内容,希望文章能够帮你解决php 标头(位置:)不会重定向所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。