Cless Posted July 20, 2007 Share Posted July 20, 2007 Hi. What do you think would be the best method of stopping some from refreshing a page with POST data? Lately, some idiot has been refreshing pages with POST, so it keeps creating rows and stuff. Thanks. Quote Link to comment Share on other sites More sharing options...
benjaminbeazy Posted July 20, 2007 Share Posted July 20, 2007 automatically redirect after processing mysql input using header() if you wanna be really sure, add a time log that disallows an insert from the same ip and such before a certain amount of time, or something like that Quote Link to comment Share on other sites More sharing options...
Cless Posted July 20, 2007 Author Share Posted July 20, 2007 Ah. I've never heard of that command. Could you please give a little explanation on how to use it? Quote Link to comment Share on other sites More sharing options...
me102 Posted July 20, 2007 Share Posted July 20, 2007 You could use cookies, make a cookie and make it expire when you want to allow the person to insert more data. Quote Link to comment Share on other sites More sharing options...
Cless Posted July 20, 2007 Author Share Posted July 20, 2007 Yeah. I suppose. But for this, I need the user to be able to input data immediately. Quote Link to comment Share on other sites More sharing options...
TheFilmGod Posted July 20, 2007 Share Posted July 20, 2007 Use session. After the post occurs make php set a variable like $post = "done"; Then on the post page have a conditional if ($post == "done") { header() } else { show form... } Quote Link to comment Share on other sites More sharing options...
Cless Posted July 20, 2007 Author Share Posted July 20, 2007 That's what I tried, however, if you refresh, the page sends the POST data again, thus, it's basically the same as clicking the button. Quote Link to comment Share on other sites More sharing options...
TheFilmGod Posted July 20, 2007 Share Posted July 20, 2007 clear the post data after the script is done. Unset $_post['user'] , something like that! Would that work? Quote Link to comment Share on other sites More sharing options...
Cless Posted July 20, 2007 Author Share Posted July 20, 2007 Ah, that will probably work. I'll see if it does. I was wondering how to unset POST data anyways. ;p Quote Link to comment Share on other sites More sharing options...
DeadEvil Posted July 20, 2007 Share Posted July 20, 2007 put this after inserting record to vanished $_POST variable.. header ('location: pagename.php'); Quote Link to comment Share on other sites More sharing options...
Cless Posted July 20, 2007 Author Share Posted July 20, 2007 Hmm... I can't figure out where that would go. Do you know where it would go in this?: <?PHP //Include Cookie File include("cookie1.php"); //Include Top File include("top2.html"); //Include Submit File include("submit.html"); //Display Description And Content echo "<hr> <b>-Promotional Pokémon-</b><br /> <hr> <small>Sometimes, Staff will be nice and give you a Promotional (Promo) Pokémon. They are free. Pokémon obtained will be automatically sent to your Box.</small><br /><br />"; //Set Variables $GP_Submit= $_POST['GP_Submit']; if(!$GP_Submit) { if($GotPromo=="Yes") { echo "Sorry, $Username, you have already obtained the current Promotional Pokémon, $PromoName."; } else { echo "The current Promotional Pokémon is...<br /><br /> <img src='/IMG/$Promo1/$Promo2/$Promo3/$Promo'><br /> <b>$PromoName</b><br /><br /> <form method='POST'> <input type='submit' id='sbt_btn' name='GP_Submit' class='forminput' value='Obtain' onclick='hide_btn(this);' /> <span id='submit_btn_msg' style='display:none'>Loading...</span> </form>"; } } //Otherwise, Submit Data else { echo "Promotional Pokémon successfully obtained!<br /><br />"; $AddPoké="Yes"; $AddPoké1=$PromoName; $AddPoké2=$PromoGender; include("AddPoke.php"); mysql_query("UPDATE Users SET Promo='Yes' WHERE Username='$Username'"); unset($GLOBALS['_POST']['GP_Submit']); } //Include Bottom File include("bottom2.html"); ?> Thanks. Quote Link to comment Share on other sites More sharing options...
DeadEvil Posted July 20, 2007 Share Posted July 20, 2007 above statement of else Quote Link to comment Share on other sites More sharing options...
Cless Posted July 20, 2007 Author Share Posted July 20, 2007 Like that?: <?PHP //Include Cookie File include("cookie1.php"); //Include Top File include("top2.html"); //Include Submit File include("submit.html"); //Display Description And Content echo "<hr> <b>-Promotional Pokémon-</b><br /> <hr> <small>Sometimes, Staff will be nice and give you a Promotional (Promo) Pokémon. They are free. Pokémon obtained will be automatically sent to your Box.</small><br /><br />"; //Set Variables $GP_Submit= $_POST['GP_Submit']; if(!$GP_Submit) { if($GotPromo=="Yes") { echo "Sorry, $Username, you have already obtained the current Promotional Pokémon, $PromoName."; } else { echo "The current Promotional Pokémon is...<br /><br /> <img src='/IMG/$Promo1/$Promo2/$Promo3/$Promo'><br /> <b>$PromoName</b><br /><br /> <form method='POST'> <input type='submit' id='sbt_btn' name='GP_Submit' class='forminput' value='Obtain' onclick='hide_btn(this);' /> <span id='submit_btn_msg' style='display:none'>Loading...</span> </form>"; header ('location: pagename.php'); } } //Otherwise, Submit Data else { echo "Promotional Pokémon successfully obtained!<br /><br />"; $AddPoké="Yes"; $AddPoké1=$PromoName; $AddPoké2=$PromoGender; include("AddPoke.php"); mysql_query("UPDATE Users SET Promo='Yes' WHERE Username='$Username'"); unset($GLOBALS['_POST']['GP_Submit']); } //Include Bottom File include("bottom2.html"); ?> Quote Link to comment Share on other sites More sharing options...
DeadEvil Posted July 21, 2007 Share Posted July 21, 2007 like this one.. //Otherwise, Submit Data else { header ('location: pagename.php'); ... Quote Link to comment Share on other sites More sharing options...
Cless Posted July 22, 2007 Author Share Posted July 22, 2007 I tried it, didn't work. :S I get this error message: Warning: Cannot modify header information - headers already sent by (output started at /usr/export/www/vhosts/funnetwork/hosting/tpmrpg/top2.html:148) in /usr/export/www/vhosts/funnetwork/hosting/tpmrpg/promo.php on line 44 Quote Link to comment Share on other sites More sharing options...
DeadEvil Posted July 23, 2007 Share Posted July 23, 2007 its because of the include and echo... ok try this one <? //Include Cookie File require_once("cookie1.php"); //Include Top File require_once("top2.html"); //Include Submit File require_once("submit.html"); //Display Description And Content /*echo */ $content = ""; $content .= "<hr> <b>-Promotional Pokémon-</b><br /> <hr> <small>Sometimes, Staff will be nice and give you a Promotional (Promo) Pokémon. They are free. Pokémon obtained will be automatically sent to your Box.</small><br /><br />"; //Set Variables $GP_Submit= $_POST['GP_Submit']; if(!$GP_Submit) { if($GotPromo=="Yes") { $content .= "Sorry, $Username, you have already obtained the current Promotional Pokémon, $PromoName."; } else { $content .= "The current Promotional Pokémon is...<br /><br /> <img src='/IMG/$Promo1/$Promo2/$Promo3/$Promo'><br /> <b>$PromoName</b><br /><br /> <form method='POST'> <input type='submit' id='sbt_btn' name='GP_Submit' class='forminput' value='Obtain' onclick='hide_btn(this);' /> <span id='submit_btn_msg' style='display:none'>Loading...</span> </form>"; header ('location: gotopagename.php'); } } //Otherwise, Submit Data else { $content .= "Promotional Pokémon successfully obtained!<br /><br />"; $AddPoké="Yes"; $AddPoké1=$PromoName; $AddPoké2=$PromoGender; include("AddPoke.php"); mysql_query("UPDATE Users SET Promo='Yes' WHERE Username='$Username'"); unset($GLOBALS['_POST']['GP_Submit']); header ('location: gotopagename.php'); } print $content; //Include Bottom File require_once("bottom2.html"); ?> 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.