passing variables to another script
Posted: Fri Apr 04, 2003 3:24 pm
I can't find any other problem related to mine with a solution so any answer is much appreciated.
I am able to pass the values from the form to the first php script. This script e-mails the form contents in html. It displays the values fine.
In the html message the person receives, there is a form action calling another php script. I cannot get the values in the e-mail to pass along to the next php script. I've tried hidden fields and sessions (although I may not be using sessions properly as I am new to php) and nothing seems to be working. Here is a simple example:
form:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Form Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form name="test" method="post" action="script1.php">
<p>
<input name="check" type="radio" value="Here">
Check Here</p>
<p>
<input name="check" type="radio" value="Or">
Or Here</p>
<p>Enter Text:
<input name="text" type="text" id="text">
</p>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
<p> </p>
</form>
</body>
</html>
script1.php
<?php
$htmlmsg =
"<!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv=Content-Type content=text/html; charset=iso-8859-1>
</head>
<body>
<form name=form1 method=post action=http://10.10.10.10/protect/script2.php>
<p>$check</p>
<p>$text</p>
<p>
<input type=submit name=Submit value=Submit>
</p>
<p> </p>
</form>
</body>
</html>
";
$headers = "MIME-Version: 1.0";
$headers = "Content-Type: text/html; charset=iso-8859-1";
mail("user@mail.com", "Test", $htmlmsg, $headers);
echo "Thanks!";
?>
script2.php
<?php
$htmlmsg =
"<!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN>
<html>
<head>
<title>test 2</title>
<meta http-equiv=Content-Type content=text/html; charset=iso-8859-1>
</head>
<body>
<form name=form1 method=post action=script3.php>
<input type=hidden name=check value=\"<? echo $check ?>\">
<p>$text</p>
<p>$pass</p>
<p>
<input type=submit name=Submit value=Submit>
</p>
<p> </p>
</form>
</body>
</html>
";
$headers = "MIME-Version: 1.0";
$headers = "Content-Type: text/html; charset=iso-8859-1";
mail("user@mail.com", "test 2", $htmlmsg, $headers);
echo "Thanks!";
?>
Anyway, then this script would e-mail the values to the next person. I tried using the hidden field for one variable to test. I also tried (not shown) to print them outside of the $htmlmsg variable, but that didn't work either.
Thanks.
I am able to pass the values from the form to the first php script. This script e-mails the form contents in html. It displays the values fine.
In the html message the person receives, there is a form action calling another php script. I cannot get the values in the e-mail to pass along to the next php script. I've tried hidden fields and sessions (although I may not be using sessions properly as I am new to php) and nothing seems to be working. Here is a simple example:
form:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Form Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form name="test" method="post" action="script1.php">
<p>
<input name="check" type="radio" value="Here">
Check Here</p>
<p>
<input name="check" type="radio" value="Or">
Or Here</p>
<p>Enter Text:
<input name="text" type="text" id="text">
</p>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
<p> </p>
</form>
</body>
</html>
script1.php
<?php
$htmlmsg =
"<!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv=Content-Type content=text/html; charset=iso-8859-1>
</head>
<body>
<form name=form1 method=post action=http://10.10.10.10/protect/script2.php>
<p>$check</p>
<p>$text</p>
<p>
<input type=submit name=Submit value=Submit>
</p>
<p> </p>
</form>
</body>
</html>
";
$headers = "MIME-Version: 1.0";
$headers = "Content-Type: text/html; charset=iso-8859-1";
mail("user@mail.com", "Test", $htmlmsg, $headers);
echo "Thanks!";
?>
script2.php
<?php
$htmlmsg =
"<!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN>
<html>
<head>
<title>test 2</title>
<meta http-equiv=Content-Type content=text/html; charset=iso-8859-1>
</head>
<body>
<form name=form1 method=post action=script3.php>
<input type=hidden name=check value=\"<? echo $check ?>\">
<p>$text</p>
<p>$pass</p>
<p>
<input type=submit name=Submit value=Submit>
</p>
<p> </p>
</form>
</body>
</html>
";
$headers = "MIME-Version: 1.0";
$headers = "Content-Type: text/html; charset=iso-8859-1";
mail("user@mail.com", "test 2", $htmlmsg, $headers);
echo "Thanks!";
?>
Anyway, then this script would e-mail the values to the next person. I tried using the hidden field for one variable to test. I also tried (not shown) to print them outside of the $htmlmsg variable, but that didn't work either.
Thanks.