Form to Email

I have a simple form that should send the results to a hotmail email address. It then displays a thank you page to the visitor and finally redirect to another page - for this example Google.

Everything seems to work except the results do not get sent to the email - can anyone help?

I think it might be to do with the checkboxes - how are these processed to email?

Here is the code:

The Form - survey.html

[code]

Untitled Document
Name:
Continent

Asia
Europe
Africa
North America
South America
Antarctica
Australia

Favourite Color

Orange
Yellow
Blue
Red
Other (Please Specify)

Your Comments:
 

 

[/code]

The PHP - check.php

[php]<?php
/Subject and Email Variables/
$emailSubject = ‘check.php’;
$webMaster = ‘substituteyouremailhere’;

/Gathering Data Variables/
$name = $_POST[‘name’];
$continent = $_POST[‘continent’];
$color = $_POST[‘color’];
$othercolor = $_POST[‘othercolor’];
$comments = $_POST[‘comments’];

$body = <<<EOD




Visitors Name: $name

Visitors Continent: $continent

Visitors Favourite Color: $color

Other Favourite Color: $othercolor
EOD;

$headers = “From: $email\r\n”;
$headers .= “Content-type: text/html\r\n”;
$success = mail($webMaster, $emailSubject, $body, $headers);

/* Results rendered as HTML */
$theResults = <<<EOD

Thanks - Survey Complete

Success - Thanks for completing the Form - We will get back to you soon!

EOD; echo "$theResults"; ?> [/php]

Any help would be great - thanks :wink:

Although I am very new to php. Shouldnt your form have something like this?

[php]// MAIL SUBJECT
$subject = “Email Subject Line”;
// TO MAIL ADDRESS
$to="$email";

mail($to, $subject, $msg, $headers);[/php]

That was quick WebbieWorks

At the top of the php script both a subject and an email are specified -

[php]<?php
/Subject and Email Variables/
$emailSubject = ‘check.php’;
$webMaster = ‘substituteyouremailhere’;[/php]

I think the problem relates to the form being processed and the checkboxes - if I run a form without these it doesn’t seem to cause a problem - but thanks for the quick reply :wink:

This is a long shot, but try taking out the ID, so it just looks like this

<label> <input type="radio" name="continent" value="Asia" /> Asia</label> <br /> <label> <input type="radio" name="continent" value="Europe" /> Europe</label>

and so on.

Interesting…I use the ID’s when/if styling using CSS. However, no harm in me tidying up the code a bit - might make things a bit easier. Thanks, Andy :wink:

I have checked your mail script it’s Working fine, may be your missing to define email id for $webMaster.
assign a predefine email id where you want to sent form information.

[php]
//Do one more thing replace
$success = mail($webMaster, $emailSubject, $body, $headers);
// With
$success = mail($webMaster, $emailSubject, $body, $headers);
echo $success ? “Mail sent” : “Mail failed”;

[/php]

Sanjay

Cheers Sarthak, only getting back to this now :wink:

Sponsor our Newsletter | Privacy Policy | Terms of Service