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.
passing variables to another script
Moderator: General Moderators
Predefined Variables
Just assign your variables being passed.
See $_POST, $_GET and $_REQUEST (Predefined Variables)
See $_POST, $_GET and $_REQUEST (Predefined Variables)
Code: Select all
<?php
$var=$_POST['var'];
// depending on method
$var=$_GET['var'];
?>php not showing
If this is email being sent to some one's email client and that is where they are viewing the body of the message then the php will not show because there email client would have know idea what php is.
What has to happen I think is that the action on the form has to be a call back to your site like
http://www.yoursite.com/replyemail/scri ... ar2=value2
you will probably have to use javascript or something to create the url
I will also recomend doing some testing on the values that are recieved in your script2.php to make sure nothing dangerous is being passed through.
I have done something simillar in a text file with a standared anchor link but I think the same idea should work.
phpScott
What has to happen I think is that the action on the form has to be a call back to your site like
http://www.yoursite.com/replyemail/scri ... ar2=value2
you will probably have to use javascript or something to create the url
I will also recomend doing some testing on the values that are recieved in your script2.php to make sure nothing dangerous is being passed through.
I have done something simillar in a text file with a standared anchor link but I think the same idea should work.
phpScott
Don't know that it's incredibly important, but just to warn you...
You defined $headers twice in your code.
The code will take the last version of the headers variable and use it in the script. Might want to:
a.) Put that header info on the same line
or
b.) Name the second variable something other than '$headers'.
You defined $headers twice in your code.
Code: Select all
$headers = "MIME-Version: 1.0";
$headers = "Content-Type: text/html; charset=iso-8859-1";a.) Put that header info on the same line
or
b.) Name the second variable something other than '$headers'.
more to jims post
or you can concatinate the variables like so
notice the dot. period, . thing that will then put the variables together, be careful of spacing though when doing this.
phpScott
Code: Select all
$headers = "MIME-Version: 1.0";
$headers .= " Content-Type: text/html; charset=iso-8859-1";phpScott