westman Posted July 31, 2012 Share Posted July 31, 2012 what is a simple way i can stop reposting a form when i press F5? Link to comment Share on other sites More sharing options...
birbal Posted July 31, 2012 Share Posted July 31, 2012 if you are posting using POST, it will prompt a message when user press f5 for. Link to comment Share on other sites More sharing options...
westman Posted July 31, 2012 Author Share Posted July 31, 2012 yes i see the message all the time but i would like to stop it. to stop the reposting (dubole posting) of all $_POST & $_GET Link to comment Share on other sites More sharing options...
birbal Posted July 31, 2012 Share Posted July 31, 2012 you can store the form information in session with timestamp. and check the form information and timestamp when your process it. if form information is same in for a particular time span dont process the form. form information could be anything which can identify a form indipendently. like id in target url, Link to comment Share on other sites More sharing options...
westman Posted July 31, 2012 Author Share Posted July 31, 2012 like i said a simple way ;)bro am not a php master Link to comment Share on other sites More sharing options...
birbal Posted July 31, 2012 Share Posted July 31, 2012 i can't think of any other wway. it is not hard , if you did not understand any part of it you can specify it. so that it will be possible to enlighten it. Link to comment Share on other sites More sharing options...
kanchatchai Posted July 31, 2012 Share Posted July 31, 2012 When Click [New] -->$_session['saved']="FALSE"; When Click [save] -->if ($_session['saved']=="FALSE"){....SAVE...$_session['saved']="True";} Link to comment Share on other sites More sharing options...
westman Posted August 1, 2012 Author Share Posted August 1, 2012 how does this work? Link to comment Share on other sites More sharing options...
birbal Posted August 1, 2012 Share Posted August 1, 2012 do you know how to work with session? Link to comment Share on other sites More sharing options...
westman Posted August 1, 2012 Author Share Posted August 1, 2012 yes,i made a login session to a site and if the login session is not there it will logout a user Link to comment Share on other sites More sharing options...
birbal Posted August 1, 2012 Share Posted August 1, 2012 you can use session like that then. $timeSpan=300; //time in seconds//check session is set and is form is not posted within 5 minutes if(isset($_SESSION['lastFormUsed'] && $timeSpan>(time()-$_SESSION['lastFormused'])){//process form //mark last time of form processing$_SESSION['lastFormUsed']=time();}else//error handle that is the concept you can modify it to suite your needs. Link to comment Share on other sites More sharing options...
westman Posted August 1, 2012 Author Share Posted August 1, 2012 thank you so much + i got the 20% thing too. Link to comment Share on other sites More sharing options...
kanchatchai Posted August 4, 2012 Share Posted August 4, 2012 <?PHP @session_start(); if (!isset($_SESSION['userid'])) {header( 'Location: index.php') ;}?><?PHP echo '<H1>Insert New mytable</H1>'; if ((isset($_POST['submit']) )&&((isset($_SESSION['saved']))&&($_SESSION['saved']=='false')))//<----------------------------Check Session Saved and Submit{ include('connect.php'); $sql="INSERT INTO mytable(firstname,lastname) VALUES ('".$_POST['firstname']."','".$_POST['lastname']."')"; if (!mysql_query($sql,$con)) { echo 'Error While Insert : '.mysql_error();}else { echo '1 Record Insert Compleated <a href="">[New]</a> <a href="mytable_select.php">[Back To Datasheet View]'; $_SESSION['saved']='true';//<----------------------------Change Session Saved} mysql_close($con);} else {?><form id="insert_mytable" name="insert_mytable" method="POST" action="">id : AUTO<br/>firstname : <input type="text" name="firstname" /><br/>lastname : <input type="text" name="lastname" /><br/> <input type="reset" name="reset" value="Reset" /><input type="submit" name="submit" value="OK" /><br/></form><br/><?PHP$_SESSION['saved']='false';//<----------------------------First Make it False } //End IF?> Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now