PDA

View Full Version : i got the Mailer put how do i add more options?



Not2Sure
September 7th, 2003, 10:14 AM
I am trying to add a PHP form mailer to my site. i have it all set up but i want to add more things like radio buttons, check boxes, drop down list... etc.

this is Mailer.php



<?PHP
###################### Set up the following variables ######################
#
$to = "me@me.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 = "example.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 my 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>

Not2Sure
September 7th, 2003, 10:19 AM
Oh and if you need a PHP mailer just copy the first set of PHP and save as mailer.php and then copy the second set and past it in you HTML code of your site.

Not2Sure
September 7th, 2003, 11:44 AM
ok forget it now, i got it.

all you have to do is add them into the form of the HTML code.

urbaneve
October 6th, 2003, 08:03 PM
with your php --- where did you add the html (i'm curious because i thought that you didnt need to put anything in the HTML page -- of course my script didnt work and now i am wondering if that was the problem

eyezberg
October 7th, 2003, 03:01 AM
Oh and if you need a PHP mailer just copy the first set of PHP and save as mailer.php and then copy the second set and past it in you HTML code of your site. ...pretty clear, no? ;)

urbaneve
October 10th, 2003, 06:23 AM
clear as mud :beam:-- what i meant was where in the html does it get added in at

Oh and if you need a PHP mailer just copy the first set of PHP and save as mailer.php and then copy the second set and past it in you HTML code of your site.
(in the head, the body, after the body.........? sorry if i wasnt clear in asking my question.

eyezberg
October 10th, 2003, 11:44 AM
in the body, wherever you want to the form to show ;)

Not2Sure
October 10th, 2003, 11:54 AM
there should be a tutorial for this coming soon on Kirupa.com but i will explain to you Inferior Minds.... :trout:

change the first 5 lines to your options;


<?PHP
$to = "ADD YOUR EMAIL HERE";
$subject = "Results from your Request Info form";
$headers = "From: Form Mailer";
$forward = 0;
$location = "";

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



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

?>


now save as mailer.php

now add this HTML to your web page



<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>


now add the file mailer.php to the same directory as the HTML file or link to in by changing action="mailer.php" to the correct link.

hope that helped.

PS. you can add as many check boxes, input feilds and form elements you want without a single change to the PHP script. all you need to do is add the name="example" app to the code.

example: <input type="text" name="your email">

good luck with it! :)

Boatman189
October 16th, 2008, 09:29 AM
Oh and if you need a PHP mailer just copy the first set of PHP and save as mailer.php and then copy the second set and past it in you HTML code of your site.
Hi
I downlaoded your mailer and uploaded it to my site but it is not sending the submited form to my email address. It at www.thepropertyplaceinc.com/form/index.htm (http://www.thepropertyplaceinc.com/form/index.htm) if you care to look. Well any help would be appreciated of course.

Dave
boatman 189 on the forum