im trying to get my code to work but its not, i made two forms with update, delete and add buttons to get data out of my database, Vrienden is the table and Voornaam, Achternaam, Omschrijving are the fields. the update and delete buttons work just fine, im having proplems with my add button. can someon help me. code
<body>
<?php
include('menu.html');
require('db_connectie.php');
if(isset($_POST['update'])) {
$UpdateQuery = "UPDATE Vrienden SET Voornaam='$_POST[voornaam]', Achternaam='$_POST[achternaam]', Omschrijving='$_POST[omschrijving]' WHERE ID='$_POST[hidden]'";
mysql_query($UpdateQuery, $conn);
}
if(isset($_POST['delete'])) {
$DeleteQuery = "DELETE FROM Vrienden WHERE ID='$_POST[hidden]'";
mysql_query($DeleteQuery, $conn);
}
$voornaam = mysql_escape_string($_POST["addvoornaam"]);
$achternaam = mysql_escape_string($_POST["addachternaam"]);
$omschrijving = mysql_escape_string($_POST["addomschrijving"]);
if(isset($_POST['add'])) {
//$AddQuery = "INSERT INTO Vrienden (Voornaam, Achternaam, Omschrijving) VALUES ('$voornaam', '$achternaam', '$omschrijving')";
//$AddQuery("INSERT INTO Vrienden (Voornaam, Achternaam, Omschrijving) VALUES ('".$_POST['addvoornaam']."', '".$_POST['addvoornaam']."', '".$_POST['addomschrijving']."')");
$AddQuery = "INSERT INTO Vrienden (Voornaam, Achternaam, Omschrijving) VALUES ('" . $_POST['addvoornaam'] . "', '" . $_POST['addachternaam'] . "', '" . $_POST['addomschrijving'] . "')";
mysql_query($AddQuery, $conn);
}
$query = "SELECT * FROM Vrienden";
$result = mysql_query($query,$conn);
echo "<table border=0>";
echo "<tr>";
echo "<th>Voornaam</th>";
echo "<th>Achternaam</th>";
echo "<th>Omschrijving</th>";
echo "</tr>";
while($record = mysql_fetch_array($result)) {
echo '<form action=friends.php method=post>';
echo '<tr>';
echo '<td>' . '<input type="text" name="voornaam" value="' . $record['Voornaam'] . '">'.'</td>';
echo '<td>' . '<input type="text" name="achternaam" value="' . $record['Achternaam'] . '">'.'</td>';
echo '<td>' . '<input type="text" name="omschrijving" value="' . $record['Omschrijving'] . '">'.'</td>';
echo "<input type=hidden name=hidden value=" . $record['ID'] . ">";
echo '<td>' . '<input type=submit name=update value=Wijzigen > </td>';
echo '<td>' . '<input type=submit name=delete value=Verwijderen > </td>';
echo '</tr>';
echo '</form>';
}
echo '<form action=friends.php method=post';
echo '<tr>';
echo '<td><input type=text name= addvoornaam></td>';
echo '<td><input type=text name= addachternaam></td>';
echo '<td><input type=text name= addomschrijving></td>';
echo '<td><input type=submit name=add value=Toevoegen></td>';
echo '</form>';
echo '</table>';
mysql_close($conn);
?>
</body>
</html>
here is my code, the update and delete buttons work fine, but the add one isn't working. ive tried multiple solutions. is it a simple syntax problem im not seeing?