Jump to content

Recommended Posts

Hi,

Brand new here and a print designer by nature so hopefully that'll give you some idea of the type you're dealing with here.

Anyway, I designed a site and created a form in Dreamweaver and followed a tutorial to do the PHP end of the form. The problem is when the form is filled out and sent, the recipient of the email gets this:

 

<br><hr><br>

Name:  <br>

Company:  <br>

Phone:  <br>

Services Required:  <br>

 

I'm assuming it's probably not a difficult fix but I'm just lost. If needed I could dump in all the PHP so you could take a look but any help you could give would be great. Thanks in advance.

 

-236design

Link to comment
https://forums.phpfreaks.com/topic/133921--/
Share on other sites

Below is the code. I included it all which I probably didn't need to do but thank you so much for at least taking a look. Again, I know nothing about code and just followed a tutorial.

 

Oh, and your assumption about what's in the email is correct.

 

 

<?php

 

 

/* Name and Company Variables */

 

$emailSubject = 'From Website';

$webMaster = 'teri.king@tskaccounting.com';

 

/* Gathering Data Variables */

 

$namefield = $_POST['name'];

$companyfield = $_POST['company'];

$phonefield = $_POST['phone'];

$servicesfield = $_POST['services'];

 

$body = <<<EOD

<br><hr><br>

Name: $name <br>

Company: $company <br>

Phone: $phone <br>

Services Required: $services <br>

EOD;

 

$headers = "From: $name\r\r";

$headers .= "Content-type: text/html\r\n";

$success = mail($webMaster, $emailSubject, $body, $headers);

 

/* Results rendered as 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" />

<title>Untitled Document</title>

<style type="text/css">

<!--

body {

margin-left: 0px;

margin-top: 0px;

margin-right: 0px;

margin-bottom: 0px;

background-image: url(images/background.jpg);

background-repeat: repeat;

}

#apDiv1 {

position:absolute;

left:299px;

top:216px;

width:496px;

height:436px;

z-index:1;

}

.style1 {

font-size: 16px

}

#apDiv2 {

position:absolute;

left:28px;

top:732px;

width:800px;

height:45px;

z-index:2;

}

.style2 {font-size: 12px}

a:link {

color: #000000;

text-decoration: none;

}

a:visited {

text-decoration: none;

}

a:hover {

text-decoration: underline;

}

a:active {

text-decoration: none;

}

#apDiv3 {

position:absolute;

left:294px;

top:205px;

width:506px;

height:35px;

z-index:3;

}

-->

</style></head>

 

<body>

<div id="apDiv2">

  <div align="center"><span class="style2"><strong>TSK Accounting & Consulting Services</strong><br />

    teri.king@tskaccounting.com • 215-588-6658<br />

    site designed & developed by <a href="http://www.236design.com"><strong>236design</strong></a></span><br />

  </div>

</div>

<div id="apDiv3">

  <form id="form1" name="form1" method="post" action="">

    <table width="100%" border="0" cellspacing="0" cellpadding="6">

      <tr>

        <td><div align="right">

          <label for="name">Name:</label>

        </div></td>

        <td><div align="left">

          <input name="name" type="text" id="name" size="30" maxlength="90" />

        </div></td>

      </tr>

      <tr>

        <td><div align="right">

          <label for="company">Company:</label>

        </div></td>

        <td><div align="left">

          <input name="company" type="text" id="company" size="30" maxlength="90" />

        </div></td>

      </tr>

      <tr>

        <td><div align="right">

          <label for="phone">Phone:</label>

        </div></td>

        <td><div align="left">

          <input name="phone" type="text" id="phone" size="30" maxlength="12" />

        </div></td>

      </tr>

      <tr>

        <td><div align="right">

          <label for="services">Services Required:</label>

        </div></td>

        <td><div align="left">

          <textarea name="services" id="services" cols="26" rows="5"></textarea>

        </div></td>

      </tr>

      <tr>

        <td><div align="right">

          <label for="send"></label>

          <input type="submit" name="send" id="send" value="Submit" />

        </div></td>

        <td><div align="left">

          <label for="reset"></label>

          <input type="reset" name="reset" id="reset" value="Reset" />

        </div></td>

      </tr>

    </table>

  </form>

</div>

<map name="Map" id="Map"><area shape="rect" coords="484,78,542,115" href="index.html" />

<area shape="rect" coords="598,77,684,116" href="services.html" />

</map>

</body>

</html>

EOD;

echo "$theResults";

 

?>

Link to comment
https://forums.phpfreaks.com/topic/133921--/#findComment-697676
Share on other sites

You probably have to set a header in order for the email to parse the HTML, but for the missing variables, you need to surround them in quotes:

 

$body = <<<EOD

<br><hr><br>

Name: "$name" <br>

Company: "$company" <br>

Phone: "$phone" <br>

Services Required: "$services" <br>

EOD;

 

Link to comment
https://forums.phpfreaks.com/topic/133921--/#findComment-697858
Share on other sites

Thank you so much and it appears to work with those changes. One final question. On the contact page after the form is sent, it does not reset (the info remains). Just wondering if this is a simple fix. I designed a page to include a Message Sent 'message' and I'd love for that to come up but just having the form reset would be enough for me.

 

Again, than you so much for your help.

Link to comment
https://forums.phpfreaks.com/topic/133921--/#findComment-698569
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.