我有一个问题,我的插入内容只能使用一次

时间:2019-09-22 19:50:29

标签: php mysql

 <?php
require_once 'config/dbConnect.php';
$errors = array();
//variables are declared here

if (isset($_POST['register-btn'])) {
    $lastname = $_POST['lastname'];
    $firstname = $_POST['firstname'];
    $username = $_POST['username'];
    $email = $_POST['email'];
    $phone = $_POST['phone'];
    $pword = $_POST['pword'];
    $cpword = $_POST['cpword'];

    if (count($errors) === 0) {  //if no errors
        // register user
        $pword = password_hash($pword, PASSWORD_DEFAULT); //hash_password
        $token = bin2hex(random_bytes(50)); //generate_random_token
        $verified = false;

        $insert_query = "INSERT INTO users (username,user_firstname,user_lastname,user_password, user_email, user_phone, verified, token) VALUES(?, ?, ?, ?, ?, ?, ?, ?)";
        $stmt = $conn->prepare($insert_query);
        $stmt->bind_param('ssssssbs', $username, $firstname, $lastname, $pword, $email, $phone, $verified, $token);

        if ($stmt->execute()) {
            echo 'got here';

            exit();
        } else {
            $errors['db_error'] = "DATABASE_ERROR: something went wrong. failed to register";
        }
    }
}
?>

这是我的代码。我已经查了好多次了,真的不知道怎么了。也通过了我的桌子。一切都井然有序。

0 个答案:

没有答案