Jump to content

stop reposting a form


westman

Recommended Posts

if you are posting using POST, it will prompt a message when user press f5 for.

Link to comment
Share on other sites

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

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

do you know how to work with session?

Link to comment
Share on other sites

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

<?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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...