在注册页面中插入用户名时,它在 phpmyadmin 数据库中变为零 (0)

我正在使用 000webhost 到我的 android 登录/注册应用程序,当输入数据时,所有列都填充到数据库中,除了用户名它变成零并且没有错误

http://img4.mukewang.com/61322a1900011f4c05840377.jpg

http://img4.mukewang.com/61322a2000014a4b10960367.jpg

注册.php


<?php


    $name = $_POST["name"];

    $age = $_POST["age"];

    $username = $_POST["username"];

    $password = $_POST["password"];


    $statement = mysqli_prepare($con, "INSERT INTO user (name, username, age, password) VALUES (?, ?, ?, ?)");

    mysqli_stmt_bind_param($statement, "siss", $name, $username, $age, $password);

    mysqli_stmt_execute($statement);


    $response = array();

    $response["success"] = true;  


    echo json_encode($response);

?>

登录.php


    $username = $_POST["username"];

    $password = $_POST["password"];


    $statement = mysqli_prepare($con, "SELECT * FROM user WHERE username = ? AND password = ?");

    mysqli_stmt_bind_param($statement, "ss", $username, $password);

    mysqli_stmt_execute($statement);


    mysqli_stmt_store_result($statement);

    mysqli_stmt_bind_result($statement, $userID, $name, $age, $username, $password);


    $response = array();

    $response["success"] = false;  


    while(mysqli_stmt_fetch($statement)){

        $response["success"] = true;  

        $response["name"] = $name;

        $response["age"] = $age;

        $response["username"] = $username;

        $response["password"] = $password;

    }


    echo json_encode($response);

?>


慕妹3146593
浏览 207回答 1
1回答

蝴蝶刀刀

在您调用 bind param 时,您将用户名定义为整数 (i) ...mysqli_stmt_bind_param($statement,&nbsp;"siss",&nbsp;$name,&nbsp;$username,&nbsp;$age,&nbsp;$password);这应该是 s 以将其保留为字符串,并且年龄可能是整数。mysqli_stmt_bind_param($statement,&nbsp;"ssis",&nbsp;$name,&nbsp;$username,&nbsp;$age,&nbsp;$password);
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java