close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues


PHP form redirecting to thankyou.html, but not sending appropriate emails

Thread began 6/14/2012 10:06 pm by x54x25 | Last modified 6/15/2012 10:24 am by Jason Byrnes | 5246 views | 1 replies |


PHP form redirecting to thankyou.html, but not sending appropriate emails

Hi, all!

I have tried to get this contact form to work for a few days now and can not seem to find what is wrong with it. I am new at php and have only the experience of what I am reading online. Can anyone help me? I am trying to get a persons contact info and have them select as many checkboxes as they want and to know which checkboxes they chose. The form is redirecting to the thankyou.html page I created, but no email is being sent to me as the form owner, nor to the person entering the data. This is the php code:

$mailObj = mail($mailTo,$mailSubject,$mailContent,$mailHeader, "-f<>");
$to = "";
$from = $_REQUEST['email'] ;
$name = $_REQUEST['firstname'] ;
$headers = "From: $email";
$subject = "Web Contact Data";

$fields = array();
$fields{"firstname"} = "First Name";
$fields{"lastname"} = "Last Name";
$fields{"email"} = "Email Address";
$fields{"phone"} = "Phone Number";
$fields{"address"} = "Address";
$fields{"address2"} = "Address 2";
$fields{"city"} = "City";
$fields{"state"} = "State";
$fields{"zip"} = "Zip Code";

if(isset($_POST['raisefunds'])) echo 'Help raise funds checked';
if(isset($_POST['hostfundraiser'])) echo 'Host a fund raiser checked';
if(isset($_POST['hoandouts'])) echo 'Help with literature checked';
if(isset($_POST['mailings'])) echo 'Help with mailings checked';
if(isset($_POST['doorknock'])) echo 'Neighborhood walker checked';
if(isset($_POST['yardsign'])) echo 'Display a yardsign checked';
if(isset($_POST['headquarters'])) echo 'Volunteer at headquarters checked';
if(isset($_POST['hostgettoknow'])) echo 'Host a get to know checked';
if(isset($_POST['eventsetup'])) echo 'Help st up and clean up at event checked';
if(isset($_POST['eventparticipant'])) echo 'Participate at an event checked';
if(isset($_POST['internet'])) echo 'Place a banner on my website checked';
if(isset($_POST['contribution'])) echo 'Make a donation checked';
if(isset($_POST['other'])) echo 'Volunteer in some other way checked';

$body = "We have received the following information:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }

$headers2 = "From:";
$subject2 = "Thank you for contacting us";
$autoreply = "Thank you for contacting us. Somebody will get back to you as soon as possible, usualy within 48 hours. If you have any more questions, please consult our website at";

if($email == '') {print "You have not entered an email, please go back and try again";}
else {
if($firstname == '') {print "You have not entered a name, please go back and try again";}
else {
$send = mail($to, $subject, $body, $headers);
$send2 = mail($from, $subject2, $autoreply, $headers2);
{header( "Location:" );}
{print "We encountered an error sending your mail, please notify"; }

This is the corresponding html page code:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>

<table width="800" height="743" border="0" cellpadding="5">
<td height="154" colspan="2"><p>Volunteers are the driving force behind all good campaigns. </p>
<p>If you are interested in helping Frank become the next sheriff of Charlotte County, then please complete the following form and select one or more volunteer categories.</p>
<p><strong><em>We appreciate your support!</em></strong></p></td>
<td colspan="2" valign="top"><form id="form1" name="form1" method="post" action="volunteer.php">
<label for="firstname">First Name:*</label>
<input name="firstname" type="text" id="firstname" size="30" maxlength="15" />
<label for="lastname">Last Name:*</label>
<input name="lastname" type="text" id="lastname" size="30" maxlength="20" />
<label for="email">Email:</label>*
<input name="email" type="text" id="email" size="35" maxlength="35" />
<label for="phone">Phone:*</label>
<input name="phone" type="text" id="phone" size="34" maxlength="15" />
<label for="address">Address:</label>
<input name="address" type="text" id="address" size="60" maxlength="30" />
<label for="address2">Address 2:</label>
<input name="address2" type="text" id="address2" size="58" maxlength="30" />
<label for="city">City:</label>
<input name="city" type="text" id="city" size="25" maxlength="20" />
<label for="state">State:</label>
<input name="state" type="text" id="state" size="10" maxlength="4" />
<label for="zip">Zip Code:</label>
<input name="zip" type="text" id="zip" size="10" maxlength="11" />
<input type="checkbox" name="raisefunds" id="raisefunds" />
<label for="raisefunds">Campaign Fund Raising - Help raise funds</label>
<br />
<input type="checkbox" name="hostfundraiser" id="hostfundraiser" />
<label for="hostfundraiser">Campaign Fund Raising - Host a fundraiser at my home or business</label>
<br />
<input type="checkbox" name="handouts" id="handouts" />
<label for="handouts">Promotion - Hand out literature</label>
<br />
<input type="checkbox" name="mailings" id="mailings" />
<label for="mailings">Promotion - Help with mailings</label>
<br />
<input type="checkbox" name="doorknock" id="doorknock" />
<label for="doorknock">Promotion - Neighborhood walker</label>
<br />
<input type="checkbox" name="yardsign" id="yardsign" />
<label for="yardsign">Promotion - Display a yard sign at my home or business</label>
<br />
<input type="checkbox" name="headquarters" id="headquarters" />
<label for="headquarters">Promotion - Volunteer at headquarters</label>
<br />
<input type="checkbox" name="hostgettoknow" id="hostgettoknow" />
<label for="hostgettoknow">Events - Host a &quot;Get to know candidate&quot; event at my home or business</label>
<br />
<input type="checkbox" name="eventsetup" id="eventsetup" />
<label for="eventsetup">Events - Help set up and clean up at campaign events</label>
<br />
<input type="checkbox" name="eventparticipant" id="eventparticipant" />
<label for="eventparticipant">Events - Participate at events</label>
<br />
<input type="checkbox" name="internet" id="internet" />
<label for="internet">Internet - Place a banner on my website</label>
<br />
<input type="checkbox" name="contribution" id="contribution" />
<label for="contribution">Contribution - I would like to make a donation to the campaign</label>
<br />
<input type="checkbox" name="other" id="other" />
<label for="other">Other - I would like to volunteer in some other way</label>
<input type="submit" name="submit" id="submit" value="Volunteer" />
<p>&nbsp; </p>

Sign in to reply to this post

Jason ByrnesWebAssist

This is custom code, so we will not be able to offer to much assistance with this.

but this liner:
$mailObj = mail($mailTo,$mailSubject,$mailContent,$mailHeader , "-f<>");

does not look right to me, it should not have the greater than and less than brackets around the email address:
$mailObj = mail($mailTo,$mailSubject,$mailContent,$mailHeader , "");

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question





Ease of use


security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...