当我打开PHP链接时出现以下错误
注意:未定义索引:用户名位于 /storage/ssd2/225/6268225/public_html/UserSignup.php,第29行
注意:未定义索引:以电子邮件发送 /storage/ssd2/225/6268225/public_html/UserSignup.php,第29行
注意:未定义索引:输入密码 /storage/ssd2/225/6268225/public_html/UserSignup.php,第29行
注意:未定义索引:性别 /storage/ssd2/225/6268225/public_html/UserSignup.php,第29行 string(87)“将用户插入(ID,用户名,电子邮件,密码,性别) 值(null,“,”,“,”,“)” {“状态”:“成功”,“消息”:“”}
<?php
require "connection.php";
if (isset($_POST['username'])) {
$username = $_POST['username'];
}
if (isset($_POST['email'])) {
$email = $_POST['email'];
}
if (isset($_POST['password'])) {
$password = md5($_POST['password']);
}
if (isset($_POST['gender'])) {
$gender = $_POST['gender'];
}
$returnValue = array();
$sql_query = "INSERT INTO users (id, username, email, password, gender) VALUES (null, '$username', '$email', '$password', '$gender')";
var_dump($sql_query);
if($result = mysqli_query($connection,$sql_query)) {
// var_dump($result);
$returnValue["status"] = "success";
$returnValue["message"] = "";
}
else{
$returnValue["status"] = "error";
$returnValue["message"] = "User already exist. ".mysqli_error($connection);
}
echo json_encode($returnValue);
?>