【发布时间】:2021-09-26 18:15:44
【问题描述】:
以下是代码, 我不断收到未定义的功能。 我也想知道使用 mysql 和 mysqli 的区别 未捕获的错误:调用未定义的函数 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";
}
?>```
【问题讨论】:
-
原来的
mysql_*函数在 PHP 7 中被删除了。目前还不清楚为什么有人会继续使用它们。 -
切勿以明文形式或使用 MD5/SHA1 存储密码! 仅存储使用 PHP 的
password_hash()创建的密码哈希,然后您可以使用password_verify()进行验证。看看这篇文章:How to use password_hash 并了解更多关于bcrypt & password hashing in PHP