Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Oct 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Working Code but receiving BLANK email fields

    Hi all,

    Below is the code used for an online form created with PHP. I'm receiving a confirmation that the form was sent, however when I receive the email, it looks like this with obvious blank fields.


    Email:
    Name:
    Property Address:
    City:
    State:
    Zip:
    Telephone:


    Here is my code being used:

    Code:
    <!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" />
    <title>Untitled Document</title>
    <style type="text/css">
    <!--
    body {
    	background-color: #CCCCCC;
    	margin-bottom: 0px;
    	margin: 0px;
    	padding: 0px;
    }
    body,td,th {
    	font-family: Verdana, Arial, Helvetica, sans-serif;
    }
    .table {
    	width: 800px;
    	height: 1000px;
    	background-color: #FFFFFF;
    	margin-top: 0px;
    	cell-margin: 20px;
    }
    .table2 {
    	background-image: url(table_bg.png);
    	height: 600px;
    	width: 800px;
    	background-position: top;
    	margin-top: 400px;
    }
    a:link {
    	color: #000000;
    	text-decoration: none;
    }
    a:visited {
    	text-decoration: none;
    }
    a:hover {
    	text-decoration: none;
    }
    a:active {
    	text-decoration: none;
    }
    -->
    </style>
    </head>
    
    <body>
    <table class="table" align="center" border="0" cellpadding="0" cellspacing="0" width="600">
    <tbody>
    <tr>
    <td valign="top">
    <p>&nbsp;</p>
    <center><img src="table_bg2.png" />
    <p>&nbsp;</p>
    <div class="form" id="formHolder"><form name="form1" method="post" action="click-here-form.php"> 
    <table align="center" border="0" cellpadding="6" cellspacing="0" width="100%">
    <tbody>
    <tr>
    <td><label for="email"> </label>
    <div align="right">Email Address:</div>
    </td>
    <td>
    <div align="left"><input name="email" id="email" size="35" maxlength="100" type="text" /></div>
    </td>
    </tr>
    <tr>
    <td><label for="name"> </label>
    <div align="right">Name:</div>
    </td>
    <td>
    <div align="left"><input name="name" id="name" size="35" maxlength="80" type="text" /></div>
    </td>
    </tr>
    <tr>
    <td><label for="Address"> </label>
    <div align="right">Property Address:</div>
    </td>
    <td>
    <div align="left"><input name="address" id="address" size="35" maxlength="35" type="text" /></div>
    </td>
    </tr>
    <tr>
    <td><label for="city"> </label>
    <div align="right">City:</div>
    </td>
    <td>
    <div align="left"><input name="city" id="city" size="35" maxlength="12" type="text" /></div>
    </td>
    </tr>
    <tr>
    <td><label for="state"> </label>
    <div align="right">State:</div>
    </td>
    <td>
    <div align="left"><input name="state" id="state" size="35" maxlength="12" type="text" /></div>
    </td>
    </tr>
    <tr>
    <td><label for="zip"> </label>
    <div align="right">Zip:</div>
    </td>
    <td>
    <div align="left"><input name="zip" id="zip" size="35" maxlength="12" type="text" /></div>
    </td>
    </tr>
    <tr>
    <td><label for="state"> </label>
    <div align="right">Telephone Number:</div>
    </td>
    <td>
    <div align="left"><input name="telephone" id="telephone" size="35" maxlength="12" type="text" /></div>
    </td>
    </tr>
    <tr>
    <td>
    <div align="right"><label for="clear"></label> <input name="clear" id="clear" value="Reset Form" type="reset" /></div>
    </td>
    <td>
    <div align="right"><label for="submit"></label>
    <div align="left"><input name="submit" id="submit" value="Send Email!" type="submit" /></div>
    </div>
    </td>
    </tr>
    </tbody>
    </table>
    </form></div>
    </center></td>
    </tr>
    </tbody>
    </table>
    </body>
    </html>
    PHP Code:
    <?php

    /* Subject and Email Varibales */

        
    $emailSubject "Rent Jiffy Form";
        
    $webMaster "me@bcurley.com";
        
    /* Gathering Data Variables */

        
    $emailField $_POST['email'];
        
    $nameField $_POST['name'];
        
    $addressField $_POST['address'];
        
    $cityField $_POST['city'];
        
    $stateField $_POST['state'];
        
    $zipField $_POST['zip'];
        
    $telephoneField $_POST['telephone'];
        
            
    $body = <<<EOD
    <br><hr><br>
    Email: $email <br>
    Name: $name <br>
    Property Address: $address <br>
    City: $city <br>
    State: $state <br>
    Zip: $zip <br>
    Telephone: $telephone <br>
    EOD;

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

        
    $theResults = <<<EOD
    <html>
    <head>
    <title>JakesWorks - travel made easy-Homepage</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";



    ?>
    Anything will help! Thanks!

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    This is total deja vu. I swear this exact code has been posted with this exact problem before. Woah.

    Anyway...

    PHP Code:
        $emailField $_POST['email'];
        
    $nameField $_POST['name'];
        
    $addressField $_POST['address'];
        
    $cityField $_POST['city'];
        
    $stateField $_POST['state'];
        
    $zipField $_POST['zip'];
        
    $telephoneField $_POST['telephone'];
        
            
    $body = <<<EOD
    <br><hr><br>
    Email: $email <br>
    Name: $name <br>
    Property Address: $address <br>
    City: $city <br>
    State: $state <br>
    Zip: $zip <br>
    Telephone: $telephone <br>
    EOD; 
    Take a close look at the variable names you are echoing out, as opposed to the variable names you assigning $_POST values to. Notice anything?

  • #3
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts

  • #4
    Super Moderator
    Join Date
    Feb 2009
    Location
    England
    Posts
    539
    Thanks
    8
    Thanked 63 Times in 54 Posts
    Looks like some example code or something is making its rounds...

    bcurls14: You set $emailField but later use it as $email... They need to be the same.

    Also:
    $headers = "From: $email\n";
    Should be:
    $headers = "From: $email\r\n";
    lamped.co.uk :: Design, Development & Hosting
    marcgray.co.uk :: Technical blog


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •