I'm trying to dabble with php instead of cgi when it comes to creating a login page for a website. Here's what I've come up with:
<?php
 $username = mysqli_connect("localhost", "$_POST['user']", ;  
 $password = $_POST['pass'];
 $username = stripcslashes($username);
 $password = stripcslashes($password);
 $username = mysql_real_escape_string($username,$_POST['user'] );
 $password = mysql_real_escape_string($password,$_POST['pass'] );
 mysqli_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 "Failed to login!";
      }
?> 
I have received these errors upon compiling it with XAMPP Apache.
Notice: Undefined index: user in /opt/lampp/htdocs/process.php on line 2
Notice: Undefined index: pass in /opt/lampp/htdocs/process.php on line 3
Fatal error: Uncaught Error: Call to undefined function mysql_real_escape_string() in /opt/lampp/htdocs/process.php:7 Stack trace: #0 {main} thrown in /opt/lampp/htdocs/process.php on line 7
It's my first time dabbling with php and i just followed a YouTube tutorial so I really don't know how to fix this error. Any help? Thanks.
