-2

The Error

Fatal error: Cannot use isset() on the result of an expression (you can use "null !== expression" instead) in C:\xampp\htdocs\login\checklogin.php on line 11

Code

isset(md5($_POST['password'])) ? $password = $_POST['password'] : $password = '';

Thank you for your help

DarkBee
  • 16,592
  • 6
  • 46
  • 58
  • 2
    Please don't use `md5` to store passwords. Have a look at [hashing passwords](https://www.php.net/manual/en/book.password.php) – DarkBee Jun 03 '20 at 05:50
  • 1
    You should not be using MD5 for passwords. PHP has quite mature password hash verification with [`password_hash()`](https://www.php.net/manual/en/function.password-hash.php) and [`password_verify()`](https://www.php.net/manual/en/function.password-verify.php) – Phil Jun 03 '20 at 05:51

1 Answers1

2

It is giving you the error because you are using a function inside of isset()

You should use it this way -

$password = isset($_POST['password'])) ? md5( $_POST['password'] ) : '';

In ternary operator, it returns the value according to the condition true or false

Alok Mali
  • 2,821
  • 2
  • 16
  • 32
  • Thanks for your help .| and I get this error Fatal error: Uncaught Error: Call to undefined function mysql_query() in C:\xampp\htdocs\login\checklogin.php:20 Stack trace: #0 {main} thrown in C:\xampp\htdocs\login\checklogin.php on line 20 My code on line 20 $sql = mysql_query("SELECT * FROM tb_member WHERE email ='".$_POST['email']."' AND password ='".md5($_POST['password'])."'"); //count result data – Masternimmmm Jun 03 '20 at 06:12