PHP Form AutoResponder

ccasmoe00

In Runtime
Messages
197
Ok..... I'm stuck on something here. I have a form for a client of mine and he wants the form to be able to grab the email the users input into the form, and then be able to send an auto response to that email inputted.

I've figured out how to make it work, but I just cant get the php code to grab the email put in by the user.

This is what I have:

<?php
//--------------------------Set these paramaters--------------------------

// Subject of email sent to you.
$subject = 'First Saturdays Guestlist';

// Your email address. This is where the form information will be sent.
$emailadd = 'guestlist@thefirstsaturdays.com';

// Where to redirect after form is processed.
$url = 'http://www.google.com';

// Makes all fields required. If set to '1' no field can not be empty. If set to '0' any or all fields can be empty.
$req = '0';

// Email address put into Email Field<br />
$email_field = "Email";
<--------(If I put my email address here it works, so I just need the code that goes here to grab the email the users put in)

// --------------------------Do not edit below this line--------------------------
$auto_respond_subject = 'Thank you for contacting us!';
$auto_respond_body = "Thank you getting in touch with us!\nWe aim to respond to all enquiries within 24hours etc etc \n = line break";
mail($email_field, $auto_respond_subject, $auto_respond_body);
$text = "Results from form:\n\n";
$space = ' ';
$line = '
';
foreach ($_POST as $key => $value)
{
if ($req == '1')
{
if ($value == '')
{echo "$key is empty";die;}
}
$j = strlen($key);
if ($j >= 20)
{echo "Name of form element $key cannot be longer than 20 characters";die;}
$j = 20 - $j;
for ($i = 1; $i <= $j; $i++)
{$space .= ' ';}
$value = str_replace('\n', "$line", $value);
$conc = "{$key}:$space{$value}$line";
$text .= $conc;
$space = ' ';
}
mail($emailadd, $subject, $text, 'From: '.$emailadd.'');
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
?>
 
you need a form that they submit an email address to

Code:
<form name="email" method="post" action="script_name.php">
<input type="text" name="email" />
<input type="submit" />
</form>

then the email line of the script you posted about needs to be
Code:
$email_field = $_POST['email'];
 
Back
Top Bottom