I'm currently working on taking data from my form "form.php" and sending that to "index.php" where i'm using PDO statements to insert those values into the MySQL database. In MySQL I have it set up where firstname and lastname can not be null because the data is going to be submitted back to website where the First Name + Last Name = Full Name and that full name pops up on the supporters list.
My question is,
If I don't want to set MySQL to accept a NULL value, what should I change in my PHP to accept values from the form and submit that to the database with the value attached to that instance of that specific user? I tried php.net/docs and the other StackOverflow questions didn't fully solve my challenge, any help is greatly appreciated

FORM.PHP
<form action="../index.php" method="post">
<fieldset class="form-group">
<label for="firstname">First Name</label>
<input type="text" name="firstname" class="form-control" id="firstname" placeholder="First Name">
</fieldset>
<fieldset class="form-group">
<label for="lastname">Last Name</label>
<input type="text" name="lastname" class="form-control" id="lastname" placeholder="Last Name">
</fieldset>
<fieldset class="form-group">
<label for="exampleInputEmail1">Email address</label>
<input type="text" name="email" class="form-control" id="email" placeholder="Enter email">
<small class="text-muted">We'll never share your email with anyone else.</small>
</fieldset>
<button type="submit" id="form-button" class="btn btn-primary">Submit</button>
</form>
I am sending that to index.php which is where I am receiving the error!
"Error in connection to databaseSQLSTATE[23000]: Integrity constraint violation: 1048 Column 'firstname' cannot be null"
Here is my index.php code
$form = $_POST;
$id = $form['id'];
$firstname = $form['firstname'];
$lastname = $form['lastname'];
$email = $form['email'];
try {
$db = new PDO("mysql:host=" . DB_HOST. ";dbname=" .DB_NAME .";port=".DB_PORT,DB_USER,DB_PASS);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$add_supporter = $db->prepare("INSERT INTO supporters (id, firstname, lastname, email)
VALUES (:id, :firstname, :lastname, :email)");
$add_supporter->bindParam(":id", $id);
$add_supporter->bindParam(":firstname", $firstname);
$add_supporter->bindParam(":lastname", $lastname);
$add_supporter->bindParam(":email", $email);
$add_supporter->execute();
} catch (Exception $e) {
echo "Error in connection to database" . $e->getMessage() . "</br>";
die();
}
!empty()or alter your column to contain a default value. The former is better.if (!isset($_POST['firstname'],$_POST['lastname'],$_POST['email'])) { yourErrorHandlerHere(); }btw: Your form has no input control with id/name="id"; you might want to drop it from the sql query completely and let mysql handle that field automagically.