Page 1 of 1
passing value to another page
Posted: Sat Aug 27, 2005 11:24 pm
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.
Posted: Sat Aug 27, 2005 11:26 pm
by feyd
form could post the the second page, or you could store the information in a session...
Posted: Sun Aug 28, 2005 12:14 am
by s.dot
.... or URL or cookie
Posted: Sun Aug 28, 2005 2:20 am
by shiznatix
Code: Select all
<form method="post" action="process.php">
or
Code: Select all
<form method="get" action="process.php">
Posted: Sun Aug 28, 2005 3:00 am
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
}
