Question: I keep receiving multiple error messages when i try to pull my username and password from my database table. Notice : Undefined index: user in
I keep receiving multiple error messages when i try to pull my username and password from my database table.
Notice: Undefined index: user in C:\wamp64\www\Websites\login\process.php on line 3 Notice: Undefined index: pass in C:\wamp64\www\Websites\login\process.php on line 4 Notice: Undefined variable: localhost in C:\wamp64\www\Websites\login\process.php on line 8 Notice: Undefined index: $username in C:\wamp64\www\Websites\login\process.php on line 8 Warning: mysqli_real_escape_string() expects parameter 1 to be mysqli, null given in C:\wamp64\www\Websites\login\process.php on line 8 Notice: Undefined index: $password in C:\wamp64\www\Websites\login\process.php on line 9 Warning: mysqli_real_escape_string() expects exactly 2 parameters, 1 given in C:\wamp64\www\Websites\login\process.php on line 9 Fatal error: Uncaught Error: Call to undefined function mysql_query() in C:\wamp64\www\Websites\login\process.php:20 Stack trace: #0 {main} thrown in C:\wamp64\www\Websites\login\process.php on line 20
Process.php
//connect to database $user = "root"; $pass = "MONAMAKER"; $db = "login";
$db = new mysqli('localhost', $user, $pass, $db) or die("Unable to connect");
//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 Successful!!!"; }else{ echo "Failed to login";} ?>
login.php file
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
