/    Sign up×
Community /Pin to ProfileBookmark

auto reply after form submit

Hi,

I made booking form and thank you page where i use some data from form

example Dear name thank you for booking with us ?

now i integrate auto replay to user and i try to do that like this

<?php if(mail($to, $subject, $message, $headers)) {
$to = $_POST[‘var_email’]; $message = ‘Thank you’; } else { echo “Error”; }; ?>

and i dont get email ? :CRY: ?

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@aleksa1302authorSep 23.2014 — I uploaded 2 pages where i wana fit mail replay ?

http://speedy.sh/5DRjc/thankyou-tpl.php
Copy linkTweet thisAlerts:
@jedaisoulSep 23.2014 — I suspect that "var_email" is the problem, but that is only a guess. You need to show us the form code to see whether that is the case...
Copy linkTweet thisAlerts:
@NogDogSep 23.2014 — [code=php]<?php if(mail($to, $subject, $message, $headers)) {
$to = $_POST['var_email']; $message = 'Thank you'; } else { echo "Error"; }; ?>[/code]
[/quote]

Well, that's probably not going to do what you want it to do, since it will try to send the email first, and then if it somehow succeeds, it will [i]then[/i] try to set the $to and $message values you presumably wanted to use in the email call. I think you want something more along these lines:
[code=php]
<?php
if(!empty($_POST['var_email'])) {
$to = preg_replace('[rn]', '', $_POST['var_email']);
$subject = "Set subject here"; // where do you set this?
$message = 'Thank you';
$headers = "From: [email protected]: PHP/" . phpversion();
if(mail($to, $subject, $message, $headers) == false) {
// handle mail error here
}
}
else {
// handle error for no email provided from form
}
[/code]
×

Success!

Help @aleksa1302 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.27,
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,
)...