0

I have a problem. I did not understand exactly what the problem is. I tried more than one way but I could not find the solution. I think this is the right place. I hope someone will help me.

if(isset($login)){
if(empty($adminMail) || empty($adminPass)){
echo "<div class='alert alert-danger'>"."Please enter your username and password "."</div>";
}
else{

$query="SELECT * FROM admin WEHRE email=$adminMail AND password=$adminPass";
$result= mysqli_query($conn,$query);
$row = mysqli_fetch_assoc($result);
      echo $row['email'];
}        
}   
  • 3
    You should use a prepared statement instead. Then your error would magically disappear. – Qirel Aug 28 '20 at 21:35
  • Also, ***HASH YOUR PASSWORDS***, storing them in plaintext is not secure at all! – Qirel Aug 28 '20 at 21:35
  • **Warning:** You are wide open to [SQL Injections](https://stackoverflow.com/a/60496/1839439) and should use parameterized **prepared statements** instead of manually building your queries. They are provided by [PDO](https://php.net/manual/pdo.prepared-statements.php) or by [MySQLi](https://php.net/manual/mysqli.quickstart.prepared-statements.php). Never trust any kind of input! Even when your queries are executed only by trusted users, [you are still in risk of corrupting your data](http://bobby-tables.com/). [Escaping is not enough!](https://stackoverflow.com/q/5741187) – Dharman Aug 28 '20 at 21:51
  • **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 Aug 28 '20 at 21:51
  • See [this answer](https://stackoverflow.com/a/7537500/285587) for the proper syntax – Your Common Sense Aug 29 '20 at 02:53

0 Answers0