php文件无法向表中插入数据

ncgqoxb0  于 2021-06-19  发布在  Mysql
关注(0)|答案(1)|浏览(310)

这个问题在这里已经有答案了

引用-这个错误在php中是什么意思(36个答案)
两年前关门了。
我需要支持请,我的php文件不能插入post数据从一个窗体到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();
?>
2wnc66cl

2wnc66cl1#

$email        =$_POST{'email'];

根据我的想法这里是问题,试试这个

$email        =$_POST['email'];

相关问题