用户已在db中注册。当我通过在网络上输入必要信息提交时,它将刷新并且不会将数据存储在数据库中。我认为$ _get命令有问题。我试图接收作为该表的外键的id并将数据存储到数据库中。
<? include_once 'session.php';
include_once 'newtryconn.php';
include_once 'utilities.php';
if(isset($_POST['preferences'])){
$religion = $_POST['religion'];
$home = $_POST['home'];
$occuption = $_POST['occuption'];
$roommates = $_POST['roommates'];
$phone = $_POST['phone'];
if(isset($_GET['id'])) {
$id = $_GET['id'];
$sqlInsert = "INSERT INTO preferences (religion, home, occuption, roommates, phone, id)
VALUES (:religion, :home, :occuption, :roommates, :phone, :id)";
//use PDO prepared to sanitize data
$statement = $db->prepare($sqlInsert);
//add the data into the database
$statement->execute(array(':religion' => $religion, ':home' => $home, ':occuption' => $occuption, ':roommates' => $roommates, ':phone' => $phone, ':id' => $id));
header("location: homepage.php");
}
}
?>