-4

Below is the Code, I keep getting undefined function. Also I wanted to Know the difference in between using mysql and mysqli Uncaught Error: Call to undefined function mysql_query()

```<?php

//Check if the user has filled in the details.// 

if( !Isset($_POST['username'],$_POST['password']))
{
die ("<script>alert('Please Fill Both Username and Password')
</script>");
    } 
else
{
session_start();

//check on the posted values 

$username= $_POST[('username')];
echo $username;
include('conn.php');

$password=$_POST[('password')];
echo $password;

}
//Verify Password
$result=mysql_query("Select * From user_`enter code here`info
where username='$username' AND passsword='$password'");
//Count the number if it exists
$total=mysql_num_rows($result);
//check if the credentials exists

If($total==1){
echo"Validated";
}
else{
echo"dead";
}


?>```
  • 1
    The original `mysql_*` functions were removed in PHP 7. It’s unclear why anyone would continue to use them. – esqew Jul 19 '21 at 02:23
  • 1
    Does this answer your question? [Why shouldn't I use mysql\_\* functions in PHP?](https://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php) – Tangentially Perpendicular Jul 19 '21 at 03:08
  • 1
    **Never store passwords in clear text or using MD5/SHA1!** Only store password hashes created using PHP's [`password_hash()`](https://php.net/manual/en/function.password-hash.php), which you can then verify using [`password_verify()`](https://php.net/manual/en/function.password-verify.php). Take a look at this post: [How to use password_hash](https://stackoverflow.com/q/30279321/1839439) and learn more about [bcrypt & password hashing in PHP](https://stackoverflow.com/a/6337021/1839439) – Dharman Jul 19 '21 at 10:05

1 Answers1

-3

mysql_query() was depreciated in PHP previous versions. Now you have to use mysqli_query() instead. Replace this part of the code with yours

 //Verify Password
$result=mysqli_query("Select * From user_`enter code here`info
where username='$username' AND passsword='$password'");
//Count the number if it exists
$total=mysqli_num_rows($result);
//check if the credentials exists