dtdvbf37193 2019-05-08 18:53
浏览 82

更改表格注册后无效,为什么?

After changing the table when I signup it gives errors like I didn't type anything. "username required". This is the code for the username it used to work properly before.

if(empty(trim($_POST["Username"]))){
        $Username_err = "Please enter a username.";
    } else{
        // Prepare a select statement
        $sql = "SELECT id FROM users WHERE Username = ?";

        if($stmt = mysqli_prepare($link, $sql)){
            // Bind variables to the prepared statement as parameters
            mysqli_stmt_bind_param($stmt, "s", $param_Username);

            // Set parameters
            $param_Username = trim($_POST["Username"]);

            // Attempt to execute the prepared statement
            if(mysqli_stmt_execute($stmt)){
                // store result 
                mysqli_stmt_store_result($stmt);

                if(mysqli_stmt_num_rows($stmt) == 1){
                    $Username_err = "This username is already taken.";
                } else{
                    $Username = trim($_POST["Username"]);
                }
            } else{
                echo "Oops! Something went wrong. Please try again later.";
            }
        }         
        // Close statement
        mysqli_stmt_close($stmt);
    }

I dropped the previous table just to learn more and I added a new one with the same name.

CREATE TABLE IF NOT EXISTS users (
ID INT(8) NOT NULL AUTO_INCREMENT,
FirstName varchar(255),
LastName varchar(255),
Text varchar(255),
Country varchar(255),
City varchar(255),
Email varchar(255),
Mobile BIGINT(20),
Username varchar(255),
Password varchar(255),
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT UC_users UNIQUE (ID)
);

This is the table now, what am I missing?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 使用EMD去噪处理RML2016数据集时候的原理
    • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
    • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
    • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
    • ¥15 如何在炒股软件中,爬到我想看的日k线
    • ¥15 seatunnel 怎么配置Elasticsearch
    • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
    • ¥15 (标签-MATLAB|关键词-多址)
    • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
    • ¥500 52810做蓝牙接受端