I have a button outside of my form that triggers some jQuery but for some reason it also performs the action of the form.
I checked this post Performs form action even out of the form but I don't have the same thing that causes the problem.
<form action="edit.php" method="post">
<div class="table">
<table cellspacing="0">
<tr class="top">
<th>Titel</th>
<th>Auteur</th>
<th>ISBN13</th>
<th>Uitgever</th>
<th>Pagina's</th>
<th>ID</th>
<th></th>
<th></th>
</tr>
<?php
$sql = "SELECT * FROM books";
$result = $conn->query($sql);
if ($result->num_rows > 0){
while($row = $result->fetch_assoc()){
?>
<tr>
<th><?php echo $row['title']; ?></th>
<th><?php echo $row['author']; ?></th>
<th><?php echo $row['isbn13']; ?></th>
<th><?php echo $row['publisher']; ?></th>
<th><?php echo $row['pages']; ?></th>
<th><?php echo $row['id']; ?></th>
<th><a href="edit.php?id=<?php echo $row['id']; ?>">Edit</a?</th>
<th>
<form action="common/delete.php" method="post">
<button type="submit" name="delete">Delete</button>
<input type="hidden" name="id" value="<?php echo $row['id']; ?>">
</form>
</th>
</tr>
<?php
}
} else {
echo "Sorry, maar er zijn nog geen boeken in het assortiment.";
}
$conn->close();
?>
</table>
</div>
</form>
<button class="cancel2">Annuleren</button>
The jQuery worked before I added all the code in the table and it still does but it also sends you to edit.php even tho its outside of the form