Hoi,

Als ik een rij insert in mijn database, worden er soms 1, soms 2, soms 3 en soms zelfs 4 dezelfde rijen in mijn database ingevoegd. Ik gebruik het volgende script:

$db = mysql_connect("localhost", "root", "password");
mysql_select_db("mydb", $db);

$sql = "INSERT INTO Berichten (naam, bericht) VALUES ('$_GET[naam]', '$_GET[bericht]')";
$result = mysql_query($sql,$db);

Het is me echt een raadsel waarom php besluit om meerdere rijen in te voegen. Weet iemand hoe dit komt en hoe het is op te lossen? Bij voorbaat dank.
Ik heb nu ook optie 2 geprobeerd, maar 't werkt helaas ook niet. Anyways, bedankt voor je hulp
Ik heb nu ook de 2e optie geprobeerd. Maar dat werkte helaas ook niet. Anyway, bedankt voor je hulp.
post je code in zijn 'totaalheid' eens?
<html>
<head>
<title>Test</title>
</head>
<body>
<?php
If(isset($_POST[naam))
{
$db = mysql_connect("localhost", "root", "password");
mysql_select_db("mydb", $db);

$sql = "INSERT INTO Berichten (naam, bericht) VALUES ('$_GET[naam]', '$_GET[bericht]')";
$result = mysql_query($sql,$db);
If ($result)
{
echo "Gelukt.<br>";
}
else
{
echo "Mislukt.";
}
}
else
{
?>
<form method="post">
<input type="text" name="naam"><br>
<input type="test" name="bericht"><br>
<input type="submit" value="submit">
</FORM>
<?php
}
?>
</body>
</html>

Reageren