PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
dazzclub
Forum Newbie
Posts: 3 Joined: Fri Sep 16, 2005 6:01 am
Location: flint, north wales
Post
by dazzclub » Fri Sep 16, 2005 6:11 am
Hi peolpe, i have a form for users to fill in and once it has been submitted to me., the user will automaticly be sent an e-mail to them from me telling them thanks.
is this possible?
here is my code if it helps
Code: Select all
<?php
if(isset($_POST['submit'])) {
$to = "myemail@me.co.uk";
$subject = "Form Tutorial";
$name_field = $_POST['name'];
$email_field = $_POST['email'];
$message = $_POST['message'];
$menu = $_POST['select'];
foreach($_POST['check'] as $value) {
$check_msg .= "Checked: $value\n";
}
"<select name=\"select\">";
"<option value=\"prod 1\">prod 1</option>";
"<option value=\"prod 2\">prod 2</option>";
"<option value=\"Alt 3\">Alternative 3</option>";
"<option value=\"Alt 4\">Alternative 4</option>";
"<option value=\"Alt 5\">Alternative 5</option>";
"</select>";
$body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message $check_msg $menu";
echo "Data has been submitted to $to!";
mail($to, $subject, $body);
} else {
echo "blarg!";
}
?>
shiznatix
DevNet Master
Posts: 2745 Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:
Post
by shiznatix » Fri Sep 16, 2005 6:49 am
of course! you are already sending a e-mail to you, well then if you have their e-mail address just use mail() again and put in their email address as the e-mail address it is being sent to and you will be solid, just put in your own custom message like thanks mate or whatnot
dazzclub
Forum Newbie
Posts: 3 Joined: Fri Sep 16, 2005 6:01 am
Location: flint, north wales
Post
by dazzclub » Fri Sep 16, 2005 8:24 am
hi, thanks for your help, so wot u told would work like this, if i understood it.
the user will complete my form, then send it to me but at the same time, they will recieve an e-mail from me in their post box saying thank you.
is that correct?
cheers
shiznatix
DevNet Master
Posts: 2745 Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:
Post
by shiznatix » Fri Sep 16, 2005 9:30 am
Code: Select all
<?php
if(isset($_POST['submit'])) {
$to = "myemail@me.co.uk";
$subject = "Form Tutorial";
$name_field = $_POST['name'];
$email_field = $_POST['email'];
$message = $_POST['message'];
$menu = $_POST['select'];
foreach($_POST['check'] as $value) {
$check_msg .= "Checked: $value\n";
}
"<select name=\"select\">";
"<option value=\"prod 1\">prod 1</option>";
"<option value=\"prod 2\">prod 2</option>";
"<option value=\"Alt 3\">Alternative 3</option>";
"<option value=\"Alt 4\">Alternative 4</option>";
"<option value=\"Alt 5\">Alternative 5</option>";
"</select>";
$body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message $check_msg $menu";
echo "Data has been submitted to $to!";
mail($to, $subject, $body);//this sends you the email if i am not mistaken
mail($email_field, 'Thanks Bro', 'Thanks, I got your message and your a champ.');//this will e-mail them saying thanks!
} else {
echo "blarg!";
}
?>
dazzclub
Forum Newbie
Posts: 3 Joined: Fri Sep 16, 2005 6:01 am
Location: flint, north wales
Post
by dazzclub » Fri Sep 16, 2005 10:12 am
lol, i tried that and it didnt work for me. you must have a special touch, cheers, thanks for your help.
one little more question. In the thank you email, can you attach images at all?
thanks for your help
shiznatix
DevNet Master
Posts: 2745 Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:
Post
by shiznatix » Fri Sep 16, 2005 10:15 am
you can send attachments, but i don't think with regular php mail() function unless there are some headers... there is a class, probably on phpclasses website or somthing, thats a bit trickier thing that I have never done. but you can send html emails and put the picture in the e-mail itself without making it a attachment
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Fri Sep 16, 2005 10:31 am
mail() can do attachments, it's a bit of a pain.. but it can be done..
I prefer to use
phpMailer since it's already done for me then
viewtopic.php?t=34242 is the most recent Code Snippet involving attachments using mail()