I'm writing a simple program in php that requires users to login. I have a working code but whenever a wrong username or password is entered, I got an exception that says the following:
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in C:\wamp\www\Directory\login.php on line 67
The script I have is working well, but I just need to get rid of this warning message. Below is my php code.
<?php
$username = $_POST['username'];
$password = $_POST['password'];
// Connect to the database
$con = mysql_connect('localhost', 'root', '');
// Make sure we connected succesfully
if (!$con) {
die('Connection Failed' . mysql_error());
}
// Select the database to use
mysql_select_db("Garden", $con);
$q = mysql_query("select * from register where username='" . $username . "' and password='" . $password . "' ") or die(mysql_error());
$res = mysql_fetch_row($q);
if ($res) {
header('location:home.php');
} else {
echo 'Error. The Username or Password that you entered is invalid.';
}
?>
I dont know if im using something. This is my first time of using php. Please I need your help. Thank you.