尝试使用PHP创建登录系统,不确定我的代码有什么问题

时间:2017-10-15 16:13:18

标签: php mysql login

我正在使用我的HTML将数据传递给下面的PHP表单。

<?php

session_start();

include_once 'connect_to_db.php';

if($_SERVER["REQUEST_METHOD"] == "POST"){

    $fname = trim($_POST['user-fname']);
    $fname = strip_tags($fname);
    $fname = htmlspecialchars($fname);

    $lname = trim($_POST['user-lname']);
    $lname = strip_tags($lname);
    $lname = htmlspecialchars($lname);

    $email = trim($_POST['user-email']);
    $email = strip_tags($email);
    $email = htmlspecialchars($email);

    $pass = trim($_POST['user-password']);
    $pass = strip_tags($pass);
    $pass = htmlspecialchars($pass);
    $pass = hash($pass);

    $mail_query = mysql_query("SELECT user-email FROM User WHERE user-email='$email'");
    $ifthere = mysql_num_rows($mail_query);

    if ($ifthere!=0){
        $error = true;
        $mailexist = "The email provided is already registered with us, if you forgot your password, please use reset password";
    }
}

mysql_query("INSERT INTO User(user-fname, user-lname, user-email, user-password) VALUES('$fname', '$lname', '$email', '$pass'"));

?>

我不确定发生了什么,它会加载我的php页面,但只是失败并显示错误“无法处理此查询。

0 个答案:

没有答案