new to PHP here I have a page that loops through a DB and displays the contents of the table. When the delete button is pressed I would like to delete that entry in the DB. Right now when the button is pressed and the page goes to delete.php I keep getting Undefined index: userid
Here is the first page:
<?php
foreach($rows as $row){
$userid = $row['userid'];
$pName = $row['pName'];
$pDesc = $row['pDesc'];
$dDate = $row['dDate'];
?>
<div class="project-container">
<label>Project ID:</label>
<span><?php echo $userid; ?></span><br>
<label>Project Owner:</label>
<span><?php echo $pName; ?></span><br>
<label>Project Description:</label>
<span><?php echo $pDesc; ?> </span><br>
<label>Project Due Date:</label>
<span><?php echo $dDate; ?> </span><br>
<br>
<form action="#" method="GET">
<input type="submit" name="delete" value="Delete Project">
</form>
<form action="index.php">
<input type="submit" name="update" value="Update Project">
</form>
</div>
<br>
<br>
</div><br><br><?php } ?>
and this is delete.php:
include('connect.php');
$userid = $_GET['userid'];
echo $userid;
$sql = "DELETE FROM projecttable WHERE userid = '$userid'";
$conn->exec($sql);
Any help is appreciated, thank you