AsiaUnderworld Posted March 27, 2009 Share Posted March 27, 2009 Hi, ive got some simple code, kind of a guestbook like thing where people can type their name and message and post it, however if you hit refresh, it sends it again, so you can spam, any way of me stopping this? <?php if(isset($_POST['submit'])) { $name = mysql_real_escape_string($_POST['name']); $msg = mysql_real_escape_string($_POST['msg']); if (strlen($name) < 1) echo "<div align=center>Please enter your name</div>"; elseif(strlen($msg) < 1) echo "<div align=center>Please Enter a message</div>"; else { $sql = mysql_query("INSERT INTO guest (postername,content) VALUES ('$name','$msg')"); if($sql) echo "<div align=center>Message posted</div>"; else echo "<div align=center>There was a problem.</div>"; } } ?> Link to comment https://forums.phpfreaks.com/topic/151434-php-sendsubmit-refreshing-can-spam/ Share on other sites More sharing options...
ricmetal Posted March 27, 2009 Share Posted March 27, 2009 of what i understand: either use re-captcha (or any other interface, as long as the user has to type in something diferent every time they refresh the page), or send the user to another page where refreshing doesnt interfere with the submition form Link to comment https://forums.phpfreaks.com/topic/151434-php-sendsubmit-refreshing-can-spam/#findComment-795454 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.