我偶然发现了一些问题。我的checkuser.php不应该重定向到成员区域页面。
基本上login.html发送到checkuser.php,然后应该重定向到login_success.php
这里是代码`
<?
/* Check User Script */
session_start(); // Start Session
include 'db.php';
// Conver to simple variables
$username = $_POST['username'];
$password = $_POST['password'];
if((!$username) || (!$password)){
echo "Please enter ALL of the information! <br />";
include 'login_form.html';
exit();
}
// Convert password to md5 hash
$password = md5($password);
// check if the user info validates the db
$sql = mysql_query("SELECT * FROM users WHERE username='$username' AND password='$password' AND activated='1'");
$login_check = mysql_num_rows($sql);
if($login_check > 0){
while($row = mysql_fetch_array($sql)){
foreach( $row AS $key => $val ){
$$key = stripslashes( $val );
}
// Register some session variables!
session_register('first_name');
$_SESSION['first_name'] = $first_name;
session_register('last_name');
$_SESSION['last_name'] = $last_name;
session_register('email_address');
$_SESSION['email_address'] = $email_address;
session_register('special_user');
$_SESSION['user_level'] = $user_level;
mysql_query("UPDATE users SET last_login=now() WHERE userid='$userid'");
header("Location: login_success.php");
}
} else {
echo "You could not be logged in! Either the username and password do not match or you have not validated your membership!<br />
Please try again!<br />";
include 'login_form.html';
}
?>
任何帮助表示感谢。
由于
答案 0 :(得分:1)
你不应该在你之前回复/打印一些东西
header("Location: login_success.php");
答案 1 :(得分:0)
删除$
foreach( $row AS $key => $val ){
$$key = stripslashes( $val );
}
像这样:
foreach( $row AS $key => $val ){
$key = stripslashes( $val );
}
答案 2 :(得分:-1)
你看到的错误是什么?
如果是“输出已启动”,则检查db.php
和checkuser.php
两次,如果他们有任何字符标记<?php ?>
,则会导致header
无效。在大多数情况下,空间被遗忘在某处。