Jump to content

php send/submit , refreshing can spam


AsiaUnderworld

Recommended Posts

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

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

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.