Php coding help please?

  • Thread starter Thread starter Jorge M
  • Start date Start date
J

Jorge M

Guest
Well it looks like you're displaying the HTML no matter what happens. You should only be echoing $theResults if $success is true. If the mail() doesn't work then you need to give more information as it's a problem with your server.
 
I don't know where ive made a mistake here, send mail isnt working, although the rendered html will be displayed. Could anyone help me, please? Here is the code.

<?php

/* Subject and email variables */

$emailSubject = 'Crazy php scripting!';
$webMaster = 'myname@domainname...';

/* Data variables */

$nameField = $_POST['name'];
$emailField = $_POST['email'];
$inquiryField = $_POST['inquiry'];

$body = <<<EOD
<br><hr><br>
Name: $name <br>
Email: $email <br>
Inquiry: $inquiry <br>
EOD;

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

/* Results rendered in Html */

$theResults = <<<EOD
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><style type="text/css">
<!--
body {
background-image: url(images/background-colour.jpg);
background-color: #4164F2;
background-repeat: repeat-x;
}
.style4 {color: #FFFF66}
-->
</style>
<p><p>
<div><text><center><h2 class="style4">Your message has been sent. I will get back to you as soon as i can.<br />
Thanks.</h2>
</center>
</div>
</body>
</html>
EOD;
echo "$theResults";

?>
I contacted my server and they said mail() works fine.
 
Back
Top