gpt4 book ai didi

mysql - PHP登录问题

转载 作者:行者123 更新时间:2023-11-29 08:35:20 25 4
gpt4 key购买 nike

我正在创建一个链接到数据库的登录名,当输入信息时,登录名会运行一个空白页面并且不执行任何操作,下面是我的代码:

    include "conn.php";
session_start();

$email_address = $_POST['email_address'];
$password = $_POST['password'];

if ($email_address && $password)
{
$connect = mysql_connect("computing","i7906890","password") or die ("couldn't connect!");
mysql_select_db("i7906890") or die ("couldn't find database");
$guery = mysql_query("SELECT * FROM UserAccount WHERE email_address = '$email_address'");

if ($numrows!=0) {
//code to login
while ($row = mysql_fetch_assoc($query)) //Password Check
{
$dbemail_address = $row['email_address']
$dbpassword = $row['password']
}
//Check if they match
if ($email_address==$dbemail_address&&$password==$dbpassword)
{
echo "You're in! <a href='user_page.php'>click</a> here to enter the members page";
$_SESSION['user']==$dbemail_address;
}
else
echo "Incorrect Password!";
}
else
die("That user doesn't exist!");
}
else
die("Please enter an email address and password!");
?>

这也是我的表格

<form action = "login2.php" method ="POST">
<p><img src="images/space.gif" width="70px" height="1px"/><strong>Log in</strong> or <a href="register_form.php"><strong>Register</strong></a><br>
Email:<img src="images/space.gif" width="34px" height="1px"/><input type="text" name="user" size="33"> <br>
Password:<img src="images/space.gif" width="10px" height="1px"/><input type="password" name="password" size="33"> <br>
<div align="center">
<input type="submit" value="Log in" class="button">
</div>
</p>
</form>

请帮忙!求救

最佳答案

您的代码中缺少一些 ; ,这导致脚本崩溃并且不显示任何内容。 (特别是在 while 循环中,但也请检查其他地方。)

编辑:您可能还需要考虑放弃 while 循环,并将密码条件放入 SQL 语句中以获得更好的性能。正如另一位发帖者所说,请注意 SQL 注入(inject)。

关于mysql - PHP登录问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15410850/

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