Jump to content

PHP email problem


Brad55

Recommended Posts

I have a little problem with my email script that I can't figure out why it's doing this. The email gets sent but no from email address is in the email and no text.

Here is the HTML code for the form.

<form id="facilitator" name="facilitator" method="post" action="http://www.mysite.com/emailf/email.php">
    <table width="100%" border="0" align="center">
      <tr>
        <td width="176"><div align="right">
          <label for="email2">Email:</label>
        </div></td>
        <td width="167"><div align="left">
          <input name="email" type="text" id="email" size="35" maxlength="80" />
        </div></td>
          </tr>
      <tr>
        <td><div align="right">
          <label for="name">Full Name:</label>
        </div></td>
        <td><div align="left">
          <input name="name" type="text" id="name" size="35" maxlength="80" />
        </div></td>
          </tr>
      <tr>
        <td><div align="right">
          <label for="phone">Phone Number:</label>
        </div></td>
        <td><div align="left">
          <input name="phone" type="text" id="phone" size="35" maxlength="14" />
        </div></td>
          </tr>
      <tr>
        <td><div align="right">
          <label for="comments">Comments:</label>
        </div></td>
        <td><div align="left">
          <textarea name="comments" id="comments" cols="38" rows="5"></textarea>
        </div></td>
          </tr>
      <tr>
        <td><div align="right"></div></td>
        <td><div align="left"></div></td>
          </tr>
      <tr>
        <td><div align="right">
          <label for="clear"></label>
          <input type="reset" name="clear" id="clear" value="Reset Form!" />
        </div></td>
        <td><div align="left">
          <label for="submit"></label>
          <input type="submit" name="submit" id="submit" value="Submit Email!" />
        </div></td>
          </tr>
      <tr>
        <td colspan="2"><div align="right"></div>	          <div align="left"></div></td>
          </tr>
        </table>
      </form>

This is the PHP code to send the email.

<?php

/* Subject and Email Variables */

$emailSubject = 'Facilitor at Warfighter Tech!';
$webMaster = 'myemail@email.com';
    
/* Gathering Data Variables */

$emailField = $POST['email'];
    $nameField = $POST['name'];
    $phoneField = $POST['phone'];
    $commentsField = $POST['comments'];
    
    $body = <<<EOD
<br><hr><br>
Email: $email <br>
Name: $name <br>
Phone Number: $phone <br>
Comments: $comments <br>
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
<html>
<head>
<title>Warfighter Tech Facilitor Job</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
body {
background-color: #f1f1f1;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
font-style: normal;
line-height: normal;
font-weight: normal;
color: #666666;
text-decoration: none;
}
-->
</style>
</head>

<div>
  <div align="left">Thank you for your interest! Your email will be answered very soon!</div>
</div>
</body>
</html>

EOD;
echo "$theResults";

?>

 

This is what I get in an email.

I get the Subject but no return email address and this is whats in the email.

<br><hr><br>

Email:  <br>

Name:  <br>

Phone Number:  <br>

Comments:  <br>

 

Can anyone help me out?

 

Thanks

Link to comment
Share on other sites

You should be developing with the following directives in your php.ini file:

error_reporting = -1

display_errors = On

 

If you had it set up that way, you'd be getting notices regarding an undefined variable: $email, because that isn't the name of the variable to which you've assigned the value from the $_POST array.

Link to comment
Share on other sites

Pikachu2000,

 

Let me see if I understand you correctly.

 

Is what I need to do is change these

$body = <<<EOD

<br><hr><br>

Email: $email <br>

Name: $name <br>

Phone Number: $phone <br>

Comments: $comments <br>

EOD;

 

$headers = "From: $email\r\n";

 

to this

$body = <<<EOD

<br><hr><br>

Email: email <br>

Name: name <br>

Phone Number: phone <br>

Comments: comments <br>

EOD;

 

$headers = "From: email\r\n";

 

I'm not a programer and have never really done any thing in PHP. I got the script off the net http://www.tutvid.com/tutorials/dreamweaver/tutorials/phpFormHandler.php and put in a HTML and php file, it send an email but there is no return address and nothing in the email. I just need a simple one to receive emails.

 

Thanks for all your help.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.