下周我在学校的口头辩护......我试着寻找答案..没有人在工作,所以我想在这里问一下......
好吧..我的页面是here并且我将我的php页面连接到我的数据库(godaddy)并且它的工作..在registration.php中,你可以添加员工及其被添加到我的数据库“表“但是当我尝试login.php它说...”密码不正确“但密码在我的数据库中是正确的..
它就像..我的php可以连接到数据库 但是我的数据库不想连接到我的php页面..
我的代码出了什么问题?你能帮助我吗?请?
<?php
require('db.php');
session_start();
if (isset($_POST['username'])){
$username = $_POST['username'];
$password = $_POST['password'];
$username = stripslashes($username);
$username = mysql_real_escape_string($username);
$password = stripslashes($password);
$password = mysql_real_escape_string($password);
$query = "SELECT * FROM 'users' WHERE username='$username' and password='".md5($password)."'";
$result = mysql_query($query) or die(mysql_error());
$rows = mysql_num_rows($result);
if($rows==1){
$_SESSION['username'] = $username;
header("Location: home.php");
} else {
echo "<div class='form'><h3>Username/password is incorrect.</h3><br/><div>";
}
}else{
?>
<div class="form">
<h1>Log In</h1>
<form action="" method="post" name="login">
<input type="text" name="username" placeholder="Username" required />
<input type="password" name="password" placeholder="Password" required />
<input name="submit" type="submit" value="Login" />
</form>
</div>
<?php } ?>