Php 收割台位置不工作
我正在创建一个基本的登录和注册页面,在完成更改密码表单后,我想重定向到changepassword.php?success。如果将重定向页面输入浏览器,则该页面可以正常工作,但是在提交表单时,它会重新加载changepassword.php页面,而不是?success,并且从php代码块到下一步的所有内容都不会显示(即表单、右栏和页脚)。下面是我的changepassword.php代码:Php 收割台位置不工作,php,html,mysql,Php,Html,Mysql,我正在创建一个基本的登录和注册页面,在完成更改密码表单后,我想重定向到changepassword.php?success。如果将重定向页面输入浏览器,则该页面可以正常工作,但是在提交表单时,它会重新加载changepassword.php页面,而不是?success,并且从php代码块到下一步的所有内容都不会显示(即表单、右栏和页脚)。下面是我的changepassword.php代码: <!DOCTYPE html> <html> <?php include
<!DOCTYPE html>
<html>
<?php
include ("storescripts/init.php");
protect_page();
include ("includes/overall/head.php");
if (empty($_POST) === false){
$required_fields = array('current_password','password','password_again');
foreach ($_POST as $key=>$value) {
if (empty($value) && in_array($key, $required_fields) == true) {
$errors[] = 'Fields marked with an asterisk are required';
break 1;
}
}
if ($_POST['current_password'] === $member_data['mem_password']) {
if(trim($_POST['password']) !== trim($_POST['password_again'])){
$errors[] = 'Your new passwords do not match';
} else if (strlen($_POST['password']) <6) {
$errors[] = 'Your password must be at least 6 characters';
}
} else {
$errors[] = 'Your current password is incorrect';
}
}
?>
<body>
<?php include ("includes/overall/template_header.php");?>
<div id="mainDivShort">
<h1>Change Password</h1>
<div id="divBreak"></div>
<?php include ("includes/overall/column_left.php"); ?>
<div id="middleContent">
<?php
if (isset($_GET['success']) && empty($_GET['success'])) {
echo 'You have been registered successfully';
} else {
if (empty($_POST) === false && empty($errors) === true) {
//echo "**********************";
change_password($session_mem_id, $_POST['password']);
header('Location: changepassword.php?success');
exit();
} else if (empty($errors) === false) {
echo output_errors($errors);
}
?>
<form action="" method="post">
<ul>
<li>Current Password*: <br> <input type="password"
name="current_password">
</li>
<li>New Password*: <br> <input type="password" name="password">
</li>
<li>Repeat New Password*: <br> <input type="password"
name="password_again">
</li>
<li><input type="submit" value="Change">
</li>
</ul>
</form>
<?php }?>
</div>
<?php include ("includes/overall/column_right.php"); ?>
</div>
<?php include ("includes/overall/template_footer.php");?>
</body>
</html>
数据库上的密码更新很好,只是没有重定向到成功页面。
提前感谢您不能放置
标题('Location:changepassword.php?success')代码>输出任何内容后。另外,标题
重定向应包含绝对路径。标题指令必须位于内容、任何内容之前,包括换行符、空格、html等。。。否则,发送标题就太晚了。一旦发送了1位内容,标题就已经消失了。如果您之前没有进行“回显”或“打印”,则标题将起作用,因此在标题
需要在任何输出之前和任何html之前输出任何内容。如果在此之前输出任何html,则使用标题
没有任何意义OK,但是“echo”您已成功注册“;”只有满足以下if语句的条件,才会变为真。那么,还有什么办法呢?不是下行投票者,但没有必要使用绝对路径
@Mr.Alien HTTP/1.1需要一个绝对URI作为参数»Location:Ok,但“echo”您已成功注册“;”只有满足以下if语句的条件,才会变为真。那么,除此之外,还可以如何安排呢?
function change_password($mem_id, $password) {
$mem_id = (int)$mem_id;
mysql_query("UPDATE `members` SET `mem_password` = '$password' WHERE `mem_id` = $mem_id");
}