PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
jayace
Forum Newbie
Posts: 1 Joined: Mon Oct 03, 2011 11:48 am
Post
by jayace » Mon Oct 03, 2011 11:54 am
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";
?>
Celauran
Moderator
Posts: 6427 Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada
Post
by Celauran » Mon Oct 03, 2011 12:35 pm
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.
flying_circus
Forum Regular
Posts: 732 Joined: Wed Mar 05, 2008 10:23 pm
Location: Sunriver, OR
Post
by flying_circus » Mon Oct 03, 2011 3:42 pm
at a minimum it looks like you are missing semi-colons after $webMaster and you mail function call.
egg82
Forum Contributor
Posts: 156 Joined: Sat Oct 01, 2011 9:29 pm
Location: Colorado, USA
Post
by egg82 » Mon Oct 03, 2011 11:03 pm
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";