a thank you email sent to them once they have filled my form

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

Post Reply
dazzclub
Forum Newbie
Posts: 3
Joined: Fri Sep 16, 2005 6:01 am
Location: flint, north wales

a thank you email sent to them once they have filled my form

Post by dazzclub »

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!"; 
} 
?>
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

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

conformation of code

Post by dazzclub »

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
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

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

break through at last

Post by dazzclub »

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
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

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()
Post Reply