gpt4 book ai didi

php登录 session

转载 作者:行者123 更新时间:2023-11-29 00:51:39 25 4
gpt4 key购买 nike

我的网页有一个登录系统。您创建用户名和密码,然后返回主页以使用正确的登录详细信息登录。我输入我的详细信息,它让我进入并出现一个警告框,上面写着“欢迎回来”。当我单击“确定”时,它会短暂显示该网页,但随后会直接返回登录页面。我已经开始 session ,因为注册页面工作正常。关于为什么登录页面这样做有什么想法吗?

代码如下:

if( empty( $_POST['client_username'] ) || empty( $_POST['client_password'] ) ) {
die('You did not fill in a required field');
}


$qry = sprintf( "SELECT client_username, client_password FROM client WHERE client_username = '%s' LIMIT 1", mysql_real_escape_string( $_POST['client_username'] ) );
$result = mysql_query( $qry );

if( $result ) {
if( mysql_num_rows( $result ) == 0 ) {
die('That username does not exist in our database.');
}
}



$info = mysql_fetch_assoc( $result );

if( md5( $_POST['client_password'] ) != $info['client_password'] ) {
die('Incorrect password, please try again.');
}


$client_id = mysql_query("SELECT* FROM client WHERE client_id = '$client_id'");

$qry = sprintf( "UPDATE client SET client_last_access = NOW() WHERE client_username = '%s'", $info['client_username'] );
if( !mysql_query( $qry ) ) {
die('Error: ' . mysql_error() );
} else {

$_SESSION['client_username'] = $info['client_username'];
$_SESSION['client_password'] = $info['client_password'];

$_SESSION['client_id'] = $client_id;


echo '<script>alert("Welcome Back");</script>';
echo '<meta http-equiv="Refresh" content="0;URL=pv.php">';
}

最佳答案

完全删除最后一行。

关于php登录 session ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8310906/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com