Go Back   Computer Forums > Web Design | Website Development > Web Programming
Join Computer forums Today

Thread Tools Search this Thread Display Modes
Old 06-12-2008, 07:27 AM   #1
In Runtime
ccasmoe00's Avatar
Join Date: Jan 2006
Posts: 197
Send a message via AIM to ccasmoe00 Send a message via Yahoo to ccasmoe00
Question PHP Form AutoResponder

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:

//--------------------------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.'">';

Intel Core 2 Duo
4G DDR2 Memory
NVidia GeForce 7300LE
7.1 High Definition Audio
500GB Hard Drive
8 USB (2.0)
ccasmoe00 is offline   Reply With Quote
Old 06-18-2008, 09:25 AM   #2
Site Team
root's Avatar
Join Date: Mar 2004
Posts: 7,872
Default Re: PHP Form AutoResponder

you need a form that they submit an email address to

<form name="email" method="post" action="script_name.php">
<input type="text" name="email" />
<input type="submit" />
then the email line of the script you posted about needs to be
$email_field = $_POST['email'];
I didn’t fight my way to the top of the food chain to be a vegetarian…
Im sick of people saying 'dont waste paper'. If trees wanted to live, they'd all carry guns.
"The inherent vice of capitalism is the unequal sharing of blessings; The inherent vice of socialism is the equal sharing of miseries."
root is offline   Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

All times are GMT -5. The time now is 08:58 PM.

Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2016, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0