I am newbie in PHP code. I have create a input text to search the wanted data from database and also a delete button to delete the selected data from page. All function works fine but after I click the delete button the selected data was deleted and came out this error.
Notice:Undefined index: search in C:\xampp\htdocs\FinalProject\search.php on line 114
Here is my code:
search.php
<?php
$con =mysqli_connect("localhost","root","","reservation");
$set =$_POST['search'];
if ($set) {
$show = "SELECT * FROM reserve WHERE Username = '$set'";
$result = mysqli_query($con, $show);
while ($row=mysqli_fetch_array($result)){ ?>
<tr>
<td><?php echo $row['ID']; ?></td>
<td><?php echo $row['Username']; ?></td>
<td><?php echo $row['Person']; ?></td>
<td><?php echo $row['Book_date']; ?></td>
<td><?php echo $row['Book_time']; ?></td>
<td><?php echo $row['Table_no']; ?></td>
<td><?php echo $row['Cus_acc']; ?></td>
<td><?php echo $row['Cus_food']; ?></td>
<td><?php echo $row['Cus_drink']; ?></td>
<td><?php echo $row['Cus_request']; ?></td>
<td><a class="del_btn" href="reserve_del.php?del=<?php echo
$row['ID']; ?>">Delete</a></td>
</tr>
<?php } ?>
<?php } ?>
reseacrh_del.php
<?php
$con = mysqli_connect('localhost','root','','reservation');
if (isset($_GET['del'])) {
$ID = $_GET['del'];
mysqli_query($con, "DELETE FROM reserve WHERE ID=$ID");
$_SESSION['msg'] = "Delete Successful.";
header("location: search.php");
}
?>
Some one help me please.. Thank you