I am trying to create a login page. But i have a problem to login the page. My login page is
<!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>
My process.php file is
<?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 ";
}
?>
But i get the error
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
Purpose of this code is to login a page with a particular username and password which are already store in database.