Page 1 of 1

REDIRECT to same page?

Posted: Fri Jan 08, 2010 9:58 am
by priyanob
Hello guys...
I want to design a php page which displays some input textboxes and one combobox for user input. After clicking on a 'Proceed' button those entered data must be sent to the same page. I know it can be used with FORM ACTION. But the problem is how can i check

a) whether the data is sent properly
b)If sent properly i have to clear the current screen and construct a new screen and display the received values in my own style.
c)I have seen in some sample php pages a tag like FORM ACTION="page.php?intDispop=1" where page.php is the same php file that i wrote the above tag. Whats the trick with this parameter intdispop=1....?

Re: REDIRECT to same page?

Posted: Fri Jan 08, 2010 10:04 am
by Charles256
I all ready replied to you in the general thread. Mod's if you delete his general thread post please put my reply in here. It still stands I believe.

Re: REDIRECT to same page?

Posted: Fri Jan 08, 2010 10:28 am
by priyanob
i welcome new replies....

Re: REDIRECT to same page?

Posted: Fri Jan 08, 2010 10:58 am
by manohoo
I don't know what Charles already posted for you, the following might be a different approach:

Code: Select all

<?php
if (!empty($_POST)) {
  if ($_POST['submitted'] and preg_match('/^[0-9]{4}$/',$_POST['value'])) {
    echo "Your form has been submitted, you entered ".$_POST['value'];
  } else {
    echo "Please try again";
  }
}
?>
 
<form action="" method="POST">
Enter a 4 digit number <input type='text' name='value' value='' />
<input type='hidden' name='submitted' value='yes' />
<input type='button' value='Go!'>
</form>
Notice that we always stay in the same file. This is accomplished by specifying action=""
Also, I use POST instead of GET, since I don't want users to change values in the URL.