I'm stuck
I want to modify a simple form mailing script so the forward-to URL will contain some of or all values submitted to the script. So the script will append "?name=Andrea&email=andrea@aol.com&message=a text message" to my provided URL for example. I'm told I need to use the $_GET method.
I need to separate and itemize my fields also. only 2-3 will be passed.
-------------Here is the script-----------
<?PHP
$to = "name@domain.com"; #set address to send form to
$subject = "Results from your test PHP script "; #email subject line
$headers = "From: Your Site"; #set the from address, or any other headers
$forward = 0; # redirect once email is sent? 1 : yes || 0 : no
$location = "referralpage.htm"; #set page to redirect to, if 1 is above
Adds time and date to the email
$date = date ("l, F jS, Y");
$time = date ("h:i A");
the message part of the email
$msg = "Below is the result of your feedback form. It was submitted on $date at $time.\n\n";
if ($SERVER['REQUEST_METHOD'] == "POST") {
foreach ($POST as $key => $value) {
$msg .= ucfirst ($key) ." : ". $value . "\n";
}
}
else {
foreach ($_GET as $key => $value) {
$msg .= ucfirst ($key) ." : ". $value . "\n";
}
}
mail($to, $subject, $msg, $headers);
if ($forward == 1) {
header ("Location:$location");
}
else {
echo "Thank you for submitting our form. We will get back to you as soon as possible.";
}
?>
-----End script------------
-----Form used for test--------------------
<HTML>
<Body>
<form action="test.php" method="post">
Name: <input type="text" name="name"><br>
Email: <input type="text" name="email"><br>
Message: <textarea name="message"></textarea><br>
<input type="submit" name="submit" value="Submit Form">
</form>
</body>
</HTML>
Thanks
Any jump-start on this would be appreciated.