Jump to content

Form that should be simple not working!


keefleef

Recommended Posts

Hi all,

 

I'm new to php and so worked my way through this tut on youtube to get the idea of sending emails from online form fields using php...

 

 

Seems to be working fine apart from it grabbing the information entered by the user.  So I'm getting blank fields in the email coming through that look like this:

 

================

 

Email:

Name:

Phone:

Budget:

No. Travelers:

Comments:

 

================

 

Can anyone see what's missing to make this work?  Text from php file and html of form field page below.....

 

Help much appreciated!

 

 

 

 

=====PHP======="contactformprocess.php"==================


<?php

/* define subject and send info */

$emailSubject = 'WEB ORDER';
$sendTo = '[email protected]';

/* gathering data variables */

$emailField = $_POST['email'];
$nameField = $_POST['name'];
$phoneField = $_POST['phone'];
$budgetField = $_POST['budget'];
$travelersField = $_POST['travelers'];
$commentsField = $_POST['comments'];
$newsletterField = $_POST['newsletter'];

$body = <<<EOD
<br><hr><br>
Email: $email <br>
Name: $name <br>
Phone: $phone <br>
Budget: $budget <br>
No. Travelers: $travelers <br>
Comments: $comments <br>
EOD;

$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($sendTo, $emailSubject, $body, $headers);

/* results as html */

$results = <<<EOD
<html>
<head>
<title>Title</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">THANKS MESSAGE!!!</div>
</div>
</body>
</html>
EOD;

echo "$results";

?>


 

 

=========html form page=========================

 


<html>
<head>
<title>Form from Tutvid.com</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;
}
#formHolder {
width: 800px;
background-color: e1e1e1;
}
-->
</style>

</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<div id="formHolder">
  <form name="form1" method="post" action="contactformprocess.php">
    <table width="100%" border="0" cellspacing="0" cellpadding="6">
      <tr>

        <td><label for="email">
            <div align="right">Email Address:</div>
          </label>
        </td>
        <td><div align="left">
          <input name="email" type="text" id="email" size="35" maxlength="100">
        </div></td>
      </tr>

      <tr>
        <td><label for="name">
            <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><label for="phone">
            <div align="right">Phone:</div>
          </label>
        </td>
        <td><div align="left">
          <input name="phone" type="text" id="phone" size="35" maxlength="12">

        </div></td>
      </tr>
      <tr>
        <td><div align="right">Budget:</div></td>
        <td><p align="left">
          <label>
            <input type="radio" name="budget" value="lessthan1000" id="budget_0">
            Less than $1,000</label>

          <br>
          <label>
            <input type="radio" name="budget" value="1000to5000" id="budget_1">
            $1,000 - $5,000</label>
          <br>
          <label>
            <input type="radio" name="budget" value="5000to10000" id="budget_2">
            $5,000 - $10,000</label>

          <br>
          <label>
            <input type="radio" name="budget" value="10000to25000" id="budget_3">
            $10,000 - $25,000</label>
          <br>
          <label>
            <input type="radio" name="budget" value="25000andup" id="budget_4">
            $25,000 and up</label>

          <br>
        </p></td>
      </tr>
      <tr>
        <td><div align="right">
          <label for="travelers">How many People?</label>
        </div></td>
        <td><div align="left">

          <select name="travelers" id="travelers">
            <option>Choose...</option>
            <option value="1">1</option>
            <option value="2">2</option>
            <option value="3">3</option>
            <option value="4">4</option>

            <option value="5">5</option>
            <option value="6">6</option>
            <option value="7">7</option>
            <option value="8">8</option>
            <option value="9">9</option>
            <option value="10">10</option>

            <option value="10+">10+</option>
          </select>
        </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="26" rows="5"></textarea>
        </div></td>
      </tr>
      <tr>
        <td><div align="right"></div></td>
        <td><div align="left">
          <input name="newsletter" type="checkbox" id="newsletter" value="subscribeme">

          <label for="newsletter">Subscribe to FREE online newsletter?</label>
        </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="right">
          <label for="submit"></label>
          <div align="left">
            <input type="submit" name="submit" id="submit" value="Send Email!">
          </div>
        </div></td>
      </tr>
    </table>
  </form>

  <p align="center">  </p>
</div>
</body>
</html>

 

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/227306-form-that-should-be-simple-not-working/
Share on other sites

Have now got it working by removing the 'field' from the post vbls....

 

So instead of

 

$emailField = $_POST['email'];

 

they read

 

$email = $_POST['email'];

 

Seems obvious that the vbls should match, but wondering why the tutorial changed them?!

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.