php email problem

Discussion in 'PHP' started by mikee.jk, Mar 6, 2008.

  1. #1
    hi guys,

    just now installed Xampp and i tried to do a php email form..
    i created the form in dreamweaver and wrote the php script for it...

    seems to be some problem there..lost in the day
    so plz help me solve this problem....
    or is there anyother better way of creating it
    here is the code
    contactus.htm
    
    <form action="mailform.php" method="post" name="form1" target="_self" id="form1">
    	  <table width="100%" border="1" cellspacing="1" cellpadding="0">
            <tr>
              <td><label for="textfield">
                <div align="right">name</div>
              </label></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="label">age</label>
              </div></td>
              <td><div align="left">
                <input name="age" type="text" id="age" size="35" maxlength="3" />
              </div></td>
            </tr>
            <tr>
              <td><div align="right">
                <label for="label2">sex</label>
              </div></td>
              <td><div align="left">
                <input name="sex" type="text" id="sex" size="35" maxlength="1" />
              </div></td>
            </tr>
            <tr>
              <td><div align="right">
                <label for="label3"></label>
                <label for="textarea">address</label>
              </div></td>
              <td><div align="left">
                <textarea name="address" cols="35" rows="5" id="address"></textarea>
              </div></td>
            </tr>
            <tr>
              <td><div align="right">
                <label for="label4">telephone</label>
              </div></td>
              <td><div align="left">
                <input name="telephone" type="text" id="telephone" size="35" maxlength="15" />
              </div></td>
            </tr>
            <tr>
              <td><div align="right">
                <label for="label3">email</label>
              </div></td>
              <td><div align="left">
                <input name="email" type="text" id="email" size="35" />
              </div></td>
            </tr>
            <tr>
              <td><div align="right">
                <label for="label5">country</label>
              </div></td>
              <td><div align="left">
                <input name="country" type="text" id="country" size="35" />
              </div></td>
            </tr>
            <tr>
              <td><div align="right"></div></td>
              <td><div align="left">
                <input name="news" type="checkbox" id="news" value="subscribeme" checked="checked" />
                <label for="checkbox">Subscribe me to the email newsletter</label>
              </div></td>
            </tr>
            <tr>
              <td><div align="right">
                <label for="Submit"></label>
                <input type="reset" name="Reset" value="reset" id="Submit" />
              </div></td>
              <td><div align="left">
                <label for="label6"></label>
                <input type="submit" name="Submit" value="Submit" id="label6" />
              </div></td>
            </tr>
          </table>
            </form>
    
    Code (markup):

    mailform.php

    
    <?php
    $emailSubject='test';
    $webMaster='some@gmail.com';
    $nameField = $_POST['name'];
    $ageField = $_POST['age'];
    $sexField = $_POST['sex'];
    $addressField = $_POST['address'];
    $telephoneField = $_POST['telephone'];
    $emailField = $_POST['email'];
    $countryField = $_POST['country'];
    $newsField = $_POST['news'];
    $body = <<<EOD
    <br><hr /><br />
    name: $name<br />
    age: $age<br />
    sex: $sex<br />
    address: $address<br />
    telephone: $telephone<br />
    email: $email<br />
    country: $country<br />
    news: $news<br />
    EOD;
    $headers = "from: $email\r\n";
    $headers .= "Content-type: text/html\r\n";
    $success = mail($webMaster, $emailSubject, $body, $headers);
    $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";
    ?>
    
    Code (markup):

     
    mikee.jk, Mar 6, 2008 IP
  2. Jawn

    Jawn Peon

    Messages:
    200
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You need a smtp server, what errors are you getting?
     
    Jawn, Mar 6, 2008 IP
  3. mikee.jk

    mikee.jk Peon

    Messages:
    21
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Parse error: syntax error, unexpected T_SL in C:\xampp\htdocs\aca\mailform.php on line 26


    this is ths error msg....

    i m getting
     
    mikee.jk, Mar 6, 2008 IP
  4. Submerged

    Submerged Active Member

    Messages:
    132
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #4
    It's picking up something with the <<EOD syntax.

    Just change line 26 to

    $theResults = '

    and line 49 to

    ';

    There are no single quotes in your HTML so it won't interfere and it should clear that error up.
     
    Submerged, Mar 8, 2008 IP