REDIRECT to same page?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
priyanob
Forum Newbie
Posts: 6
Joined: Wed Dec 09, 2009 7:09 pm

REDIRECT to same page?

Post 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....?
Charles256
DevNet Resident
Posts: 1375
Joined: Fri Sep 16, 2005 9:06 pm

Re: REDIRECT to same page?

Post 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.
priyanob
Forum Newbie
Posts: 6
Joined: Wed Dec 09, 2009 7:09 pm

Re: REDIRECT to same page?

Post by priyanob »

i welcome new replies....
User avatar
manohoo
Forum Contributor
Posts: 201
Joined: Wed Dec 23, 2009 12:28 pm

Re: REDIRECT to same page?

Post 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.
Post Reply