Page 1 of 1

Refresh

Posted: Fri Nov 14, 2003 4:37 am
by Luis Almeida
Hi all,

I´m new in php so my question may look prety basic.

the thing is, I have the folowing code wich work´s fine but after pressing the submit button every time I refresh the page (F5) it returns allways the same "Submited". How can I "reset" the form after pressing the button so if the user refreshes the page it wont execute the submit button again?

Thank´s in advance

Luis Almeida

Code: Select all

<?

	if ($SUBMIT_BUTTON)
	&#123;
		echo "Submited";
	&#125;
	else
	&#123;
		echo "Not yet Submited";
	&#125;

?>

<form action="" method="post" name="MY_FORM">
	<input name="MY_TEXT" type="text" size="20" maxlength="20">
	<input name="SUBMIT_BUTTON" type="submit">
</form>

Posted: Fri Nov 14, 2003 1:17 pm
by Weirdan

Code: Select all

<?php
   session_start();
   if ($SUBMIT_BUTTON) { 
      if(isset($_SESSION["already"]))
          echo "Already submitted";
      else{
         echo "Submited";
         $_SESSION["already"]=true;
      } 
   } else { 
      echo "Not yet Submited"; 
   } 

?> 

<form action="" method="post" name="MY_FORM"> 
   <input name="MY_TEXT" type="text" size="20" maxlength="20"> 
   <input name="SUBMIT_BUTTON" type="submit"> 
</form>

Posted: Fri Nov 14, 2003 1:20 pm
by JPlush76
I would use the header() function
once they submit the form, redirect them back to the page which will reset all the POST vars and they can refresh the page like they never submitted it.

Posted: Mon Nov 17, 2003 3:34 am
by Luis Almeida
Thank´s to both of you for helping!!