Form redirection

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
ramagates
Forum Newbie
Posts: 6
Joined: Thu Nov 11, 2004 12:16 pm
Location: Sri Lanka

Post by ramagates »

any one knows how to redirect a form to a page after submit? i mean the code!
djot
Forum Contributor
Posts: 313
Joined: Wed Jan 14, 2004 10:21 am
Location: planet earth
Contact:

Post by djot »

-
Hi,

??????? Do you want to pass a web form to a script/different page? What do you mean with passing the code? Or do you need the code for a form that is submitted to a script and processed in the script, redirecting/showing the results?

djot
-
User avatar
scorphus
Forum Regular
Posts: 589
Joined: Fri May 09, 2003 11:53 pm
Location: Belo Horizonte, Brazil
Contact:

Post by scorphus »

The following example shows how to redirect the form1's contents to procframe.php page using the POST method:

Code: Select all

<form name="form1" method="post" action="procframe.php">
<input type="text" name="name" />
<input type="submit" name="submitt" />
</form>
The input named submitt is named intentionaly, because of this.

Hope it helps. Please lemme know if it doesn't!
Scorphus.
User avatar
harrisonad
Forum Contributor
Posts: 288
Joined: Fri Oct 15, 2004 4:58 am
Location: Philippines
Contact:

RE:

Post by harrisonad »

correct me if i don't get your question right

are you talking about like this:
FORM.php -> submitted to PROCESS.php -> then redirect $_POST variables to ANOTHER.php

if that's what you're asking then i must say that you need to have another copy of the form in FORM.php to PROCESS.php with all buttons or textboxes given values from $_POST variables received from FORM.php

then, instead of redirecting to ANOTHER.php (because there is no $_POST variables sent by redirecting), just automatically submit the form on loading.

as a result, you will preserve all $_POST variables sent by FORM.php upto the ANOTHER.php

However, if this is not your question, just ignore what i have said....
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post by ol4pr0 »

Simple example

Get values from form1 and get the information on form2 just copy and paste that.

Form1.html

Code: Select all

&lt;form name="form1" action="form2.php" method="post"&gt;
Name: &lt;input type="text" name="name"&gt;&lt;/input&gt;
&lt;input type="submit" name="submit" value="Send to form2"&gt;
&lt;/form&gt;
Form2.php

Code: Select all

if (isset($_POST['submit'])) # checking if submit button has been pressed
{
  if (!empty($_POST['name'])) # checking if a name was entered
  {
   echo "You have entered the following name: " .$_POST['name']; 
   }
   else # no name was entered in the text field on form1.html
   {
    echo "Sorry but you did not enter any name";
   }
}
else # no submit button was pressed, just an example~!
{
echo "You tried to directly open this page, please go back to form1.html";
}
Post Reply