ben pas begonnen met zelf te scripten, nu wou ik een form maken die de gegevens naar de database stuurt, maar ik krijg deze error:
Notice: Undefined index: form in C:\wamp\www\sql.php on line 9
Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(naam, leeftijd) VALUES ('Dieter','17')' at line 1Form.html:
<html>
<head>
<title>Form</title>
</head>
<body>
<form action="sql.php" method="post">
Naam: <input type="text" name="naam" /> <br>
Leeftijd: <input type="text" name="leeftijd" />
<input type="submit" />
</form>
</body>
</html>
sql.php:
<?php
$con = mysql_connect("localhost","root","1425367");
if (!$con)
{
die('Kon geen contact maken met de database! ' . mysql_error());
}
mysql_select_db("tutorial",$con);
$sql="INSERT INTO " . $_POST['form'] . " (naam, leeftijd)
VALUES
('$_POST[naam]','$_POST[leeftijd]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "1 record added";mysql_close($con)
?>
knop om dit te doen.