我已经为登录和数据库制作了一个 PHP 文件,但不断出现错误
致命错误:Uncaught Error: Call to undefined function mysql_real_escape_string() in C:\wamp64\www\Login\process.php on line 15
错误:在第 15 行调用 C:\wamp64\www\Login\process.php 中未定义的函数 mysql_real_escape_string()
代码开始
<?php
// to get values passe from form in login.php file
$username = $POST['username']
$password = $POST['password']
// to prevent mysql injection
$username = stripcslashes($username);
$password = stripcslashes($password);
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($username);
//connect to the server select database
mysql_connect("localhost", "root", "");
mysql_select_db("login");
// Query the database for user
$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 "Failed to login!";
}
?>
杨__羊羊