我正在尝试创建一个登录页面。但是我无法登录页面。 我的登录页面是
<!DOCTYPE html>
<html>
<head>
<title>Login Page</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="frm">
<form action="process.php" method="POST">
<p>
<label>Username:</label>
<input type="text" id="user" name="user" />
</p>
<p>
<label>Password:</label>
<input type="password" id="pass" name="pass" />
</p>
<p>
<input type="submit" id="btn" value="Login"/>
</p>
</form>
</div>
</body>
</html>
我的process.php文件是
<?php
$username=$_POST['user'];
$password=$_POST['pass'];
$username = stripcslashes($username);
$password = stripcslashes($password);
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);
mysql_connect("localhost","root","");
mysql_select_db("login");
$result = mysql_query("select * from users where username='$username' and password = '$password' ") or die("Failed to query database".mysql_error());
$row = mysql_fetch_array($result);
if($row['username']==$username && $row['password'] == $password){
echo"Login success!!! Welcome ".$row['username'];
}
else{
echo"Login Fail ";
}
?>
但是我得到了错误
Fatal error: Uncaught Error: Call to undefined function mysql_real_escape_string() in C:\xampp\htdocs\php\process.php:7 Stack trace: #0 {main} thrown in C:\xampp\htdocs\php\process.php on line 7
此代码的目的是使用已经存储在数据库中的特定用户名和密码登录页面。