1,105,333 Community Members

Email error - PHP

Member Avatar
arobix
Newbie Poster
3 posts since Jun 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

My client tells me that when he tests this code, he is asked to supply his email address when he has already entered it. When I test it, it goes through. It used to work and now it doesn't.

Here is the code for the form (Apply_Online.php):

<table width="750" border="0" align="center" cellpadding="0" cellspacing="0" class="Form_Labels">
        <tr>
          <td>
            <form id="form1" name="form1" method="post" action="Send_Email.php">
              <table width="575" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#000000">
                <tr>
                  <td><table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#E4E4E4">
                    <tr>
                      <td width="40%" bgcolor="#D0EAD3">Name</td>
                      <td width="60%" bgcolor="#FFFFFF"><input name="name" type="text" id="name" size="40" /></td>
                    </tr>
                    <tr>
                      <td bgcolor="#D0EAD3">Email Address </td>
                      <td bgcolor="#FFFFFF"><input name="email" type="text" id="email" size="40" /></td>
                    </tr>
                    <tr>
                      <td bgcolor="#D0EAD3">Phone (if you want us to call you)</td>
                      <td bgcolor="#FFFFFF"><input name="phone" type="text" id="phone" size="20" /> 
                        (Please include area code) </td>
                    </tr>
                    <tr>
                      <td bgcolor="#D0EAD3">Loan Amount Desired </td>
                      <td bgcolor="#FFFFFF"><span>$</span>
                        <input name="amount_desired" type="text" id="amount_desired" size="15" /></td>
                    </tr>
                    <tr>
                      <td bgcolor="#D0EAD3">Purpose of Loan </td>
                      <td bgcolor="#FFFFFF"><textarea name="purpose" cols="35" rows="5" id="purpose"></textarea></td>
                    </tr>
                    <tr>
                      <td bgcolor="#D0EAD3">Loan Property Type </td>
                      <td bgcolor="#FFFFFF"><select name="property_type" id="property_type">
                        <option>Please Choose One</option>
                        <option value="Residential">Residential</option>
                        <option value="Commercial">Commercial</option>
                        <option value="Multi-Family">Multi-Family</option>
                        <option value="Condo">Condo</option>
                        <option value="Industrial">Industrial</option>
                        <option value="Building Lot">Building Lot</option>
                        <option value="Acreage">Acreage</option>
                        <option value="Mobild and Land">Mobile and Land</option>
                        <option value="Construction Loan">Construction Loan</option>
                              </select></td>
                    </tr>
                    <tr>
                      <td bgcolor="#D0EAD3">Value of Loan Property </td>
                      <td bgcolor="#FFFFFF"><span>$</span>
                        <input name="property_value" type="text" id="property_value" size="15" /></td>
                    </tr>
                    <tr>
                      <td bgcolor="#D0EAD3">Approximate 1st Mortgage Balance</td>
                      <td bgcolor="#FFFFFF"><span>$</span>
                        <input name="mortgage1" type="text" id="first_mortgage" size="15" /></td>
                    </tr>
                    <tr>
                      <td bgcolor="#D0EAD3">Approximate 2nd Mortgage Balance </td>
                      <td bgcolor="#FFFFFF"><span>$</span>
                        <input name="mortgage2" type="text" id="second_mortgage" size="15" /></td>
                    </tr>
                  </table></td>
                </tr>
                <tr>
                  <td align="right"><input type="submit" name="Submit" value="Send Email --&gt;&gt;" />
                  &nbsp;&nbsp;&nbsp;</td>
                </tr>
              </table>
            </form>
            <p>&nbsp;</p>
          </td>
        </tr>
    </table>

And here is the code for Send_Email.php:

<?php        

    if($email != null)
        {   
            // Format the currency fields so they look like money in the email
            //setlocale(LC_MONETARY, 'en_US');
            $amount_desired = number_format($amount_desired);
            $property_value = number_format($property_value);
            $mortgage1 = number_format($mortgage1);
            $mortgage2 = number_format($mortgage2);
            $head  = "MIME-Version: 1.0\r\n";
            $head .= "Content-type: text/html; charset=iso-8859-1\r\n"; 
            $head .= "From: $email\r\n";
            $to    = "rhrussell@charter.net";
            //$to    = "info@umpquawebdesign.com";      
            $subject = "Loan Request from GregRussellOregon.com";
            $body  =    "<p>Loan Request:</p>
                        <blockquote><strong>
                            Name:  $name<br />
                            Email: $email<br />
                            Phone: $phone<br />
                            Property Type: $property_type<br />
                            Amount Desired: $ $amount_desired<br />
                            Property Value: $ $property_value<br />
                            First Mortgage: $ $mortgage1<br />
                            Second Mortgage: $ $mortgage2<br />
                        </strong></blockquote>
                        <br />
                        <blockquote>
                            <strong>Purpose of Loan:</strong> $purpose<br />
                        </blockquote>";

            $retval = mail($to, $subject, $body, $head);

            if ( $retval ) // If the email was sent, redirect
                {   
                    $result = "Thank You!  Your message has been sent.<br />
                            We will be sure to get back to you just as soon as we can."; 
                }
            elseif(!$retval)
                {
                    $result = "Sorry, your message was not sent.<br />
                            Please hit your browser's Back button and try again.";
                }
        }
    else
        { $result = "Sorry, you must enter an email address so we have some idea of how to get in touch with you."; }
?>
Member Avatar
liamfriel
Junior Poster
101 posts since Oct 2009
Reputation Points: 3 [?]
Q&As Helped to Solve: 13 [?]
Skill Endorsements: 0 [?]
 
0
 

I cannot see:

$email = $_POST['email']

or anywhere that you declare $email as a variable therefore it is always false

Member Avatar
arobix
Newbie Poster
3 posts since Jun 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

I wondered if that would do it, but I wasn't positive. I'll try it.

Member Avatar
arobix
Newbie Poster
3 posts since Jun 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

It works. Thanks.

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article