我需要支持,我的PHP文件无法将表单中的发布数据插入SQL,
但是当我使用常量值而不是$_POST['name']
时,它可以工作。
<?php
$servername = "localhost";
$username = "hostingo_usrproj";
$password = "basel1990!";
$dbname = "hostingo_project";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$name =$_POST['name'];
$email =$_POST{'email'];
$usrpassword =$_POST['usrpassword'];
$mobile =$_POST['mobile'];
$sql = "INSERT INTO MyGuests (name, email, usrpassword, mobile )
VALUES ('$name', '$email', '$usrpassword', '$mobile')";
if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
?>
答案 0 :(得分:2)
$email =$_POST{'email'];
根据我的想法,这是问题
试试这个
$email =$_POST['email'];