Double post!

Hi, I have an annoying problem with my guestbok; when you post there for the FIRST time, only then, (also if you deleted your cookies…:P) You get a double post, the one is the actual post, the second one is just blank.

Is there any way you can fix this…:S? Heres my code;

echo "<center><br/><b>Sign $username's guestbook</b><br/>
<form action=\"member.php?sign=$username&from=".$_SESSION["username"]."\" method='POST'>
<textarea name='message' rows='5' cols='30' align='left'>Your message</textarea><br/>
<input type='submit' value='Update' name='submit'>

This is the code that is showing the sign guestbook box.

And this is the function.


if(isset($_GET["sign"]))
{ // Sign the guestbook
require_once("functions/DbConnector.php");
$username = $_GET["sign"];
$from = $_GET["from"];
$message = $_POST["message"];
$time = date("j. F Y, G:i");
$db = new DbConnector();
$db->connect();
$query = "INSERT INTO guestbook(username,postedby,post,time) VALUES('$username','$from','$message','$time')";
$db->query($query);
echo "Your message has been posted";


Hope this is fixable… :slight_smile:
Thank you.

Try adding LIMIT 1 to the end of your query, like this:


$query = "INSERT INTO guestbook(username,postedby,post,time) VALUES('$username','$from','$message','$time') LIMIT 1";

Got an 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 ‘LIMIT 1’ at line 1