我正在使用 000webhost 到我的 android 登錄/注冊(cè)應(yīng)用程序,當(dāng)輸入數(shù)據(jù)時(shí),所有列都填充到數(shù)據(jù)庫(kù)中,除了用戶名它變成零并且沒(méi)有錯(cuò)誤注冊(cè).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);?>
1 回答

蝴蝶刀刀
TA貢獻(xiàn)1801條經(jīng)驗(yàn) 獲得超8個(gè)贊
在您調(diào)用 bind param 時(shí),您將用戶名定義為整數(shù) (i) ...
mysqli_stmt_bind_param($statement, "siss", $name, $username, $age, $password);
這應(yīng)該是 s 以將其保留為字符串,并且年齡可能是整數(shù)。
mysqli_stmt_bind_param($statement, "ssis", $name, $username, $age, $password);
添加回答
舉報(bào)
0/150
提交
取消