I have a page that has two buttons "Yes" and "no". When I click the "yes" button, everything works fine, but when I click the "No" button, I get the error.
However, the database is still updated when i get this error but what I want is for it to go back two pages, the same way that the "Yes" button does in the code below.
edit.php
<form action="dbconfig.php" method="post">
<select name="studentId" id="" class="form-control">
<option value="">Select Student</option>
<option value="35290">student1</option>
<option value="35316">student2</option>
<option value="35294">student3</option>
<option value="35377">student4</option>
</select>
<select name="createdAt" id="" class="form-control">
<option value="">Select Time</option>
<option value="2019-04-02 11:00:00">11:00</option>
<option value="2019-04-02 12:00:00">12:00</option>
<option value="2019-04-02 13:00:00">13:00</option>
<option value="2019-04-02 15:00:00">15:00</option>
</select>
<p>
Did the student attend class?
<button name="attended" type="submit" value="1" >Yes</button>
<button name="attended2" type="submit" value="0" >No</button>
dbconfig.php
<?php
$con=mysqli_connect("localhost","root","","billy") or die ("Database
not selected");
$studentId=$_POST['studentId'];
$attended=$_POST['attended'];
$createdAt=$_POST['createdAt'];
if(isset($_POST['attended']))
{
$query=mysqli_query($con,"insert into attendance (studentId, attended,
createdAt) values ('$studentId','$attended','$createdAt')") or die
("Error");
echo '<script type="text/javascript">'
, 'history.go(-2);'
, '</script>';
}
else (isset($POST['attended2']))
{
$query=mysqli_query($con,"DELETE FROM attendance WHERE
studentId='$studentId' AND createdAt='$createdAt'") or die ("Error")
}
?>