passing value to another 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
winsonlee
Forum Commoner
Posts: 76
Joined: Thu Dec 11, 2003 8:49 pm

passing value to another page

Post by winsonlee »

index.php

contains the form where user enters the information

process.php

contains the code where it print out all the information


i just wondering how can i pass the information from index.php to process.php.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

form could post the the second page, or you could store the information in a session...
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

.... or URL or cookie
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

Code: Select all

<form method="post" action="process.php">
or

Code: Select all

<form method="get" action="process.php">
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

Heck... I'm bored.

index.php

Code: Select all

<form action="process.php" method="post">
<input type="hidden" name="flag" value="index">
<input type="text" name="foo" size="10">
<input type="text" name="bar" size="10">
<input type="submit" value="Submit">
</form>
process.php

Code: Select all

if($_POST['flag'] == "index")
{
   // All of your variables are now here, in $_POST, you could uhhh.. do whatever you want with them.
   $foo = $_POST['foo'];
   $bar = $_POST['bar'];

   // perhaps make them mysql safe?
   $foo = mysql_real_escape_string($foo);
   $bar = mysql_real_escape_string($bar);

   // print them to the browser?
   echo $foo."<br />";
   echo $bar;

   // put them in an array?
   $foobar = array('$foo','$bar');

   // print the array?
   print_r($foobar);

   // and various other things
}
:-D
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Post Reply