我正在尝试通过从数据库中检索注册的用户名/密码来创建一个非常基本的 PHP 登录。这永远不会上线,我知道输入验证为零。我要做的就是在登录时从数据库中选择数据。
这是 index.html 上的登录表单:
<table width="250" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<form name="form1" method="post" action="checklogin.php">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td colspan="3"><strong>Member Login </strong></td>
</tr>
<tr>
<td width="78">Username</td>
<td width="6">:</td>
<td width="294"><input name="Username" type="text" id="Username"></td>
</tr>
<tr>
<td>Password</td>
<td>:</td>
<td><input name="Password" type="text" id="Password"></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><input type="submit" name="Submit" value="Login"></td>
</tr>
</table>
</td>
</form>
</tr>
</table>
这是 PHP checklogin.php:
<?php
$sql_connection = mysqli_connect ("localhost:8889","root","root","derek_website_tmp");
if (mysqli_connect_errno())
{
echo "failed to connect" . mysqli_connect_error();
}
$Username=$_POST['Username'];
$Password=$_POST['Password'];
$sql = "SELECT * FROM $Members WHERE Username = '$Username' and Password = '$Password'"
$result=mysqli_query($sql);
$count = mysql_num_rows($result);
if ($count==1) {
$_SESSION['Username'] = $Username;
$_SESSION['Password'] = $Password;
header('location:login_success.php');
}
else {
echo 'Wrong Username or Password';
}
if (!mysqli_query($sql_connection))
{
die('Error : ' . mysqli_error($sql_connection));
}
mysqli_close ($sql_connection);
?>
当我尝试这个时,我得到一个错误检索 checklogin.php 任何帮助将不胜感激。