Click to See Complete Forum and Search --> : I need an autoreply email when a user submits my forms


mastreblig
01-22-2007, 04:48 AM
Hi,

As the above states I need an autoreply email to send to my customers when they submit a form.

I have a normal html form - example http://www.needtaxiquote.co.uk/article.php?aid=29 with a submit button that sends the form results to my email. I know how to set up an autoreply in Outlook/Express but the response would direct to the server as I have php details server side.

How do I get the autoreply to send to the user's email? What alternatives are there?

Thanks

Sam

Tabo
01-22-2007, 05:03 AM
You need php not html, its serverside, does your server have php?

You need the var of the email field, lets call it $email

<form method="post" action="whatever.php">

whatever.php:

::Your content here::

<script language="php">$email = $HTTP_POST_VARS[email];

$mailto = "$email";

$mailsubj = "Reply to your form sub...";

$mailhead = "From: $email\n";

reset ($HTTP_POST_VARS);

$mailbody = "Values submitted from web site form:\n";

while (list ($key, $val) = each ($HTTP_POST_VARS)) { $mailbody .= "$key : $val\n"; }

if (!eregi("\n",$HTTP_POST_VARS[email])) { mail($mailto, $mailsubj, $mailbody, $mailhead); }

</script>

mastreblig
01-22-2007, 05:43 AM
Sorry, didn't explain myself too well - I do have PHP server side.

How do I weave what I just told you into the code below?

Cheers


<?PHP

#######################################################
# This script is Copyright 2003, Infinity Web Design #
# Distributed by http://www.webdevfaqs.com #
# Written by Ryan Brill - ryan@infinitypages.com #
# All Rights Reserved - Do not remove this notice #
#######################################################

## The lines below need to be edited...

###################### Set up the following variables ######################
#
$to = "x@dna-insure.co.uk"; #set address to send form to
$subject = "Taxi Insurance Enquiry"; #set the subject line
$headers = "From: Taxi Driver"; #set the from address, or any other headers
$forward = 0; # redirect? 1 : yes || 0 : no
$location = "thankyou.htm"; #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 the form. Our specialist taxi department will get back to you as soon as possible.";
}

?>

mastreblig
01-22-2007, 06:21 AM
Test

(Posted 2 replies, nothing coming up)

Tabo
01-22-2007, 10:42 AM
Ok, add this below the other script

<script language="php">$email = $HTTP_POST_VARS[email];

$mailto = "$email";

$mailsubj = "Reply to your form sub...";

$mailhead = "From: $email\n";

reset ($HTTP_POST_VARS);

$mailbody = "Values submitted from web site form:\n";

while (list ($key, $val) = each ($HTTP_POST_VARS)) { $mailbody .= "$key : $val\n"; }

if (!eregi("\n",$HTTP_POST_VARS[email])) { mail($mailto, $mailsubj, $mailbody, $mailhead); }

</script>


Lets say the id or what ever it is of your form field that the user enters their email is called email, so the var will be $email. This will email the form results to their email address plus the text "Values submitted from web site form:"

Taschen
01-22-2007, 12:05 PM
A word of warning: you are laying your server wide open to spammers.

It wouldn't take long to write a script external to your server that takes advantage of the above unsecured mail() routine.

Rather than sending a confirmation on submit:
First check where the request is coming from, your server or not (but don't rely on IP address as this is very easy to spoof, set a time limited token) -> next check that you have a genuine email address -> then whether the address is actively used by the person supposedly submitting the form (send an email with a hardcoded message body (ie not held in a variable) requesting a response -> if a response is received then send your confirmation.

What ever you do do please don't simply fire off an email to an unverified address, it's spammer heaven.

mastreblig
01-23-2007, 02:39 AM
Lets say the id or what ever it is of your form field that the user enters their email is called email, so the var will be $email. This will email the form results to their email address plus the text "Values submitted from web site form:"

I don't want to send them the form results though... I want to send the form user an image (basically a form with a phone number and thankyou note etc.) in the form of a jpeg.

Tabo
01-23-2007, 10:41 AM
Well then change the PHP

Values submitted from web site form:
with your code and get rid of the rest