Click to See Complete Forum and Search --> : form (2)


chris9902
09-07-2003, 08:21 AM
thanks to Pyro's site i got a working PHP form and it is really good.

one thing, how do i add more input boxes and drop down lists.

this is mailer.php

<?PHP
###################### Set up the following variables ######################
#
$to = "me@this.com"; #set address to send form to
$subject = "Results from your Request Info form"; #set the subject line
$headers = "From: Form Mailer"; #set the from address, or any other headers
$forward = 0; # redirect? 1 : yes || 0 : no
$location = "yahoo.com"; #set page to redirect to, if 1 is above
#
##################### No need to edit below this line ######################

## set up the time ##

$date = date ("l, F jS, Y");
$time = date ("h:i A");

## mail the message ##

$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.";
}

?>


and this is the HTML


<form action="mailer.php" method="post">
Your Name: <input type="text" name="test"><br>
Your Email: <input type="text" name="email"><br>
Your Message:<br> <textarea name="message" rows="5" cols="30"></textarea><br>
<input type="submit" name="submit" value="Submit">
</form>

pyro
09-07-2003, 09:33 AM
Just add them into your form. The PHP script will just loop through all the $_POST (or $_GET) variables (which will be all your form fields) and email them to you...

chris9902
09-07-2003, 10:44 AM
cool

like the way bravenet works.

wow that is just what i wanted, thanks PYRO

pyro
09-07-2003, 01:50 PM
You bet... :)