hello this used to work before but since I have added a php mailer file to send an email it has stopped working. I want to be able to delete my record after the user has pressed on one of the two buttons. but right now I'm getting the error
Notice: Undefined index: id
how do I fix this?
full error
Notice: Undefined index: id in C:\xampp\htdocs\bestelapp\delete.php on line 5
Error order record: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1
codes
these are the buttons that you press and then the system will send an email and delete the records
<?php
include "navbar.php";
include "config.php";
?>
<style>
.container {
font-family: Arial, Helvetica, sans-serif;
font-size: 20px;
}
tr:first-of-type th:first-child
{
border-top-left-radius: 10px;
}
tr:first-of-type th:last-child{
border-top-right-radius: 10px;
}
</style>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.2/css/all.min.css"/>
<div class="container">
<div class="table-responsive">
<table class="table table-dark table-hover" style=" width: 50%; margin-left: auto; margin-right: auto; margin-top: 5%;">
<thead>
<tr>
<th scope="col">order_id</th>
<th scope="col">klant_id</th>
<th scope="col">broodjes_ID</th>
<th scope="col">klantnaam</th>
<th scope="col">klant email</th>
<th scope="col">Bevestigen?</th>
<th scope="col">Afwijzen</th>
</tr>
</thead>
<tbody>
<?php
$sql = "SELECT * FROM orders";
$stmt = $conn->prepare($sql);
$stmt->execute();
$result = $conn -> query($sql);
$result = $stmt->get_result();
while($row = $result-> fetch_assoc()): ?>
<tr>
<td class="order_id"><?php echo $row["order_id"];?></td>
<td class="klant_id"><?php echo $row["klant_id"];?></td>
<!--Datum is eigenlijk meer voor de klant wanneer het kan worden opgehaald daar moet ene sorrt rekensom mee worden gemaakt-->
<td class="broodjes_ID"><?php echo $row["broodjes_ID"];?></td>
<td class="klantnaam"><?php echo $row["klantnaam"];?></td>
<td class="klantemail"><?php echo $row["klantemail"];?></td>
<td><form action="mail/bevestigordermail.php?order_id=<?php echo $row['order_id']; ?>" method="get">
<button type="submit" class="btn btn-success" >class="fas fa-check" style="color: rgba(255, 255, 255, 1)"></button>
</form>
</td>
<td><form action="mail/afwijzingordermail.php?order_id=<?php echo $row['order_id']; ?>" method="get">
<button type="submit" class="btn btn-danger" >class="fas fa-times" style="color: rgba(255, 255, 255, 1)"></button>
</form>
</td>
</tr>
<?php endwhile; ?>
</tbody>
</table>
</div>
</div>
the delete file: he can't find the id in here anymore
<?php
include "config.php";
$id = $_GET['id'];
var_dump($id);
$sql = "DELETE FROM orders WHERE order_id=?";
$stmt = $conn->prepare($sql);
$stmt->bind_param('i', $id);
if ($stmt->execute()) {
echo "order deleted successfully";
} else {
echo "Error order record: " . $conn->error;
}
and lastly for (if it helps) my mail file
so when you press the button it will first fo right here and then to the delete script
<?php include "mailen.php";
include "../config.php";?>
<!-- moet ik heir prepared statements gebruiken?-->
<html>
<!-- sending a mail -->
<body>
<?php
$newtime = date('H:i', time() + 3600);
echo $newtime;
$sql = "SELECT * FROM orders";
$stmt = $conn->prepare($sql);
$stmt->execute();
$result = $conn -> query($sql);
$result = $stmt->get_result();
while($row = $result-> fetch_assoc()){
$email = $row['klantemail'];
$klant = $row['klantnaam'];
$onderwerp = "Bestelling";
$bericht = "Geachte $klant, uw bestelling is bevestigd! U kunt uw order ophalen om $newtime";
mailen($email, $klant, $onderwerp, $bericht);
}
header("Location: ../delete.php");
?>
</body>
</html>
What I have tried:
I have tried adding the id to my mail file but that doesn't do anything