/    Sign up×
Community /Pin to ProfileBookmark

Send Email After Survey Completed?

I understand you use the mail() to send an email using php, but I need to send an email in a different way. I have a survey that people need to complete, and after they submit the survey an email needs to be sent to them, so each time there will be a new email. Any advice on how I can do this? Below you will see my code:[br]

[code=php]<?php
$con = mysql_connect(“server”,”user”,”pass”);
if (!$con)
{
die(‘Could not connect: ‘ . mysql_error());
}

mysql_select_db(“my_db”, $con);

$sql=”INSERT INTO Questions (Name, Email, Age, Sex, Income, Edu, Children, Apparel)
VALUES
(‘$_POST[name]’,’$_POST[email]’,’$_POST[age]’,’$_POST[sex]’,’$_POST[income]’,’$_POST[edu]’,’$_POST[children]’,’$_POST[apparel]’)”;

if (!mysql_query($sql,$con))
{
die(‘Error: ‘ . mysql_error());
}
echo “Your information has been submitted. Thank you for your time. An email will be sent to the one provided shortly.”;

mysql_close($con)
?>

[/code]

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@stephan_gerlachOct 08.2008 — you do it with mail.

[code=php]

<?php
$con = mysql_connect("server","user","pass");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("my_db", $con);

$sql="INSERT INTO Questions (Name, Email, Age, Sex, Income, Edu, Children, Apparel)
VALUES
('$_POST[name]','$_POST[email]','$_POST[age]','$_POST[sex]','$_POST[income]','$_POST[edu]','$_POST[children]','$_POST[apparel]')";

if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "Your information has been submitted. Thank you for your time. An email will be sent to the one provided shortly.";

$subject = 'PUT YOUR SUBJECT HERE';
$message = 'YOU CAN PUT YOUR MESSAGE HERE';

$header = "From: YOUREMAILADDRESSHERErn";

mail($_POST['email'],$subject,$message,$header);

mysql_close($con)
?>


[/code]
Copy linkTweet thisAlerts:
@1234567890authorOct 08.2008 — Perfect, I thought you just put the email variable in the to field, but wanted to make sure. Can I easily put a html link in the subject of the email, or does the html break down the php?
Copy linkTweet thisAlerts:
@stephan_gerlachOct 08.2008 — You can't put an link in the subject but you can put links into the email message

Look at example 4 on this page http://uk.php.net/manual/en/function.mail.php
×

Success!

Help @1234567890 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.21,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...