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. Link to comment https://forums.phpfreaks.com/topic/60893-page-refreshing/ 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 Link to comment https://forums.phpfreaks.com/topic/60893-page-refreshing/#findComment-303017 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? Link to comment https://forums.phpfreaks.com/topic/60893-page-refreshing/#findComment-303026 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. Link to comment https://forums.phpfreaks.com/topic/60893-page-refreshing/#findComment-303028 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. Link to comment https://forums.phpfreaks.com/topic/60893-page-refreshing/#findComment-303029 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... } Link to comment https://forums.phpfreaks.com/topic/60893-page-refreshing/#findComment-303031 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. Link to comment https://forums.phpfreaks.com/topic/60893-page-refreshing/#findComment-303041 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? Link to comment https://forums.phpfreaks.com/topic/60893-page-refreshing/#findComment-303051 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 Link to comment https://forums.phpfreaks.com/topic/60893-page-refreshing/#findComment-303265 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'); Link to comment https://forums.phpfreaks.com/topic/60893-page-refreshing/#findComment-303271 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. Link to comment https://forums.phpfreaks.com/topic/60893-page-refreshing/#findComment-303292 Share on other sites More sharing options...
DeadEvil Posted July 20, 2007 Share Posted July 20, 2007 above statement of else Link to comment https://forums.phpfreaks.com/topic/60893-page-refreshing/#findComment-303303 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"); ?> Link to comment https://forums.phpfreaks.com/topic/60893-page-refreshing/#findComment-303314 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'); ... Link to comment https://forums.phpfreaks.com/topic/60893-page-refreshing/#findComment-303938 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 Link to comment https://forums.phpfreaks.com/topic/60893-page-refreshing/#findComment-304900 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"); ?> Link to comment https://forums.phpfreaks.com/topic/60893-page-refreshing/#findComment-305194 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.