I know there are many questions out there that are like this one, but I can't seem to find what I am doing wrong. I've checked multiple times for typos in both my code and database. This is my PHP code I've written to submit my form details to the database:
<?php
require_once "connect.php";
if(!empty($_POST))
{
if(isset($_POST["email"], $_POST["username"], $_POST["type"], $_POST["question"]))
{
$email = test_input($_POST["email"]);
$username = test_input($_POST["username"]);
$type = test_input($_POST["type"]);
$question = test_input($_POST["question"]);
$premium = ($_POST["premium"]);
$member = ($_POST["member"]);
if ($member != "NO")
{
$member = "YES";
}
}
if(!empty($email) && !empty($username) && !empty($type) && !empty($question))
{
$insert = $db->prepare("INSERT INTO Submissions (Email, Username, Type, Question, Member, Premium, Date) VALUES (?, ?, ?, ?, ?, ?, NOW())");
$insert->bind_param("ssssss", $email, $username, $type, $question, $member, $premium);
if($insert->execute())
{
header("Location: landing.php");
die();
}
}
}
function test_input($data)
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>
When I var_dump error call, it returned NULL, but I don't understand what that means. The connection to my database is also a success. These are my database columns: "Email", "Username", "Type", "Question", "Member", "Premium", "Date" Everything is a varChar except Question and Date. Question is a text and Date is a datetime. Also, the form fields are as followed: email, username, and question...these are input fields. type is a drop down, member and premium are check boxes.