php single submission fails and page remains the same, data is not added to the database as well. When i click the cancel button, am redirected to a new form as it should work.
How do i get the submission to work and add the form data to the database? Below is the php and form html code and attached is the form picture
<div class="form-group">
<label for="s_fname">First name</label> *
<input type="text" class="form-control" placeholder="First name">
<label for="s_lname">Last name</label> *
<input type="text" class="form-control" placeholder="Last name">
<label for="s_mname">Middle name</label>
<input type="text" class="form-control" placeholder="Middle name">
<label for="s_dob">Date of Birth</label> *
<input type="text" class="form-control" placeholder="DD/MM/YYYY">
<label for="g_phone">Phone Number</label> *
<input type="text" class="form-control" placeholder="Phone number">
<label for="g_email">Email</label> *
<input type="text" class="form-control" placeholder="Email address">
<label for="entry_year">Entry level</label> *
<input type="text" class="form-control" placeholder="Entry level">
</div>
<div class="row text-right">
<input type="submit" name="submit" value="Save" class="btn btn-default" />
 
<button type="button" class="btn btn-default" aria-label="Left Align"><a href="new_student.php">Cancel</a></button>
</div>
<?php
if (isset($_POST['submit'])) {
# process the form
$s_fname = $_POST["s_fname"];
$s_lname = $_POST["s_lname"];
$s_mname = $_POST["s_mname"];
$s_dob = $_POST["s_dob"];
$g_phone = $_POST["g_phone"];
$g_email = $_POST["g_email"];
$entry_year = $_POST["entry_year"];
$query = "insert into students (s_fname, s_lname, s_mname, s_dob, g_phone, g_email, entry_year) ";
$query .= "values ('{$s_fname}', '{$s_lname}', '{$s_mname}', {$s_dob}, {$g_phone}, {$g_email}, {$entry_year})";
$result = mysqli_query($connection, $query);
if ($result) {
# successful
redirect_to("student.php");
} else {
# failure
redirect_to("new_student.php");
}
}
?>