我的作品,但数据保存为null。我想将表格中的数据发送到表格。我怎样才能实现它?
<?php
if (isset($_POST['send-data'])) {
$firstName = $_POST['first_name'];
$lastName = $_POST['last_name'];
$idNumber = $_POST['id_number'];
$password = $_POST['password'];
$phone = $_POST['phone'];
$age = $_POST['age'];
$email = $_POST['email'];
$database->insert("test", array( "firstName" => "$firstName",
"lastName" => "$lastName", "idNumber" => "$idNumber", "password" => "$password",
"phone" => "$phone", "age" => "$age", "email" => "$email" ));
}
?>
答案 0 :(得分:0)
我认为你可以删除每个变量周围的双引号:
if (isset($_POST['send-data'])){
$firstName = $_POST['first_name'];
$lastName = $_POST['last_name'];
$idNumber = $_POST['id_number'];
$password = $_POST['password'];
$phone = $_POST['phone'];
$age = $_POST['age'];
$email = $_POST['email'];
$database->insert("test", array(
"firstName" => $firstName,
"lastName" => $lastName,
"idNumber" => $idNumber,
"password" => $password,
"phone" => $phone,
"age" => $age,
"email" => $email
));
} ?>
如果这不起作用,您应该尝试使用链接:"'.$email.'"
为每个字段