我的脚本正在返回'错误请联系支持'输出,老实说,我找不到它的问题,所以我希望新的一组眼睛能够发现这一点。我确定这只是一个小小的愚蠢错误。感谢。
<?php
session_start();
$con = mysqli_connect('localhost', 'root', '', 'test');
if (isset($_SESSION['user']) != "") {
header("Location: index.php");
}
if (isset($_POST['btn-signup'])) {
$escusername = mysqli_real_escape_string($con, $_POST['username']);
$escemail = mysqli_real_escape_string($con, $_POST['email']);
$hpassword = hash('sha512', $_POST['password']);
$query = "INSERT INTO `users` (username, email, password) VALUES('$escusername', '$escemail', '$hpassword')";
$result = mysqli_query($query);
if ($result) {
?>
<script>alert('your account has now been registered.');</script>
<?php
} else {
?>
<script>alert('error please contact support.');</script>
<?php
}
}
?>
答案 0 :(得分:0)
$result = mysqli_query($con, $query);
答案 1 :(得分:0)
@ChrisForrence有解决方案:$result = mysqli_query($con, $query);