我在localhost和live hosting上有这个代码但是当我填写用户名和密码的文本区域时,它总是在实时主机上bool(false)bool(false)但是它加起来主机的数据库但没有值因为它的错误。
当我将它运行到我的本地主机时,只需显示用户名,密码和哈希值的结果就可以了,并将其添加到数据库中。
<?php
include "db.php";
require "lib/password.php";
if (isset($_POST['submit']))
{
$username= $_POST['leguser'] ;
$password= $_POST['legpass'] ;
$pwhash = password_hash($password, PASSWORD_DEFAULT) ;
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);
echo var_dump ($username);
echo var_dump ($password);
echo var_dump ($pwhash);
$sql = "SELECT * FROM tbl_users WHERE fld_username = '$username'";
$result = $conn->query($sql);
if ($result->num_rows == true) {
echo "<script>alert('Username already used!');</script>"; }
else
{
$q = "INSERT INTO `tbl_users` (`fld_username`,`fld_password`) VALUES ('$username','$pwhash')";
$result = $conn->query($q);
if ($result) {
echo 'success';
} else {
echo 'failure: ' . mysql_error();
}
}
}
&GT;
感谢您提前获得帮助,我只是该领域的初学者:)