Page 1 of 1

PHP Mail Handler

Posted: Mon Oct 03, 2011 11:54 am
by jayace
i have a problem with this php mail handler. what is wrong with this code?

Code: Select all

<?php

	$emailSubject = 'PowerTech';
	$webMaster = 'someone@domain.com'
	
	$nameField = $_POST['name'];
	$emailField = $_POST['email'];
	$phoneField = $_POST['phone'];
	$messField = $_POST['mess'];
	
	$body = <<<EOD
<br><hr><br>
Name: $name <br>
Email: $email <br>
Phone Number: $phone <br>
Comments: $mess <br>
EOD;

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

	$theResults = <<<EOD
<p>success
<a href="index.php">click here</a> to homepage
</p>
EOD;

echo "$theResults";
?>



Re: PHP Mail Handler

Posted: Mon Oct 03, 2011 12:35 pm
by Celauran
It looks fine at a glance, although you're displaying a success message without checking the value of $success. You haven't mentioned what isn't working, though.

Re: PHP Mail Handler

Posted: Mon Oct 03, 2011 3:42 pm
by flying_circus
at a minimum it looks like you are missing semi-colons after $webMaster and you mail function call.

Re: PHP Mail Handler

Posted: Mon Oct 03, 2011 11:03 pm
by egg82
semicolons (or lack thereof) will easily kill any project

Code: Select all


         $emailSubject = "PowerTech";
         $webMaster = "someone@domain.com";
         
         $nameField = $_POST['name'];
         $emailField = $_POST['email'];
         $phoneField = $_POST['phone'];
         $messField = $_POST['mess'];
         
         $body = <<<EOD
 <br><hr><br>
 Name: $name <br>
 Email: $email <br>
 Phone Number: $phone <br>
 Comments: $mess <br>
 EOD;

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

         $theResults = <<<EOD
 <p>success
 <a href="index.php">click here</a> to homepage
 </p>
 EOD;

echo "$theResults";