manalnor Posted March 26, 2011 Share Posted March 26, 2011 Hello dear friends, I've very annoying problem :'( my website is for child drawing (draw.php) after child do drawing will click on submit (form) by sending it to another page (thanks.php) | | | | data will be submitted to database and gives message saying ( thank you for ...blah blah blah) here is the problem if he refresh the page , it will also add entry to the database so imagine if someone did many many refresh, i will get many many empty entry into database how to stop this ? here is simple code based on this problem <form name="frm" method="post" action="thanks.php"> <input type="text" name="name" id="name" value=""> <input type="text" name="email" id="email" value=""> <button type="submit">Submit</button> </form> and the (thanks.php) file code *assume we have connection to db $sql = "INSERT INTO $table (name, email) VALUES ('$name', '$email')"; mysql_query($sql, $conn) or die(mysql_error()); echo "Thank you kid..nice drawing"; now my problem if (thanks.php) got refreshed it will also will add empty entry to database can anyone please help me how to stop it. Quote Link to comment Share on other sites More sharing options...
vulcandth Posted March 26, 2011 Share Posted March 26, 2011 In you thanks script.. if you have a if ($_POST['name'] != '') { //SQL here } Basically that says, if he doesn't have any information in that field submitted.. it won't submit anything. I also recommend querying the database to make sure that he hasn't submitted anything before. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.