Skip navigation
jrandazzo1984
Currently Being Moderated

Quick help with form mailer

May 2, 2012 3:47 PM

Tags: #drop #cs5 #php #html #dreamweaver #email #down #form #code #.php

I just finished creating my form and .php file to mail it to an email address. All the input fields are working properly, except one. I can not get a drop down (Main Category) submission field to email me the submission. The form works fine on the website, the email leaves that one field blank. Any help in my coding would be greatly appreciated.

 

 

form:

 

 

<form action="merchantsignup.php" method="post" id="contact_form">

    <center><table width="637" border="0">

      <tr>

        <td>Business Name:

  <br />

    <input type="text" name="name" /></td>

        <td>Business Phone:

  <br />

    <input type="text" name="phone" /></td>

        <td>Business Email:

  <br />

    <input type="text" name="email" /></td>

      </tr>

      <tr>

        <td>Business Address:

  <br />

    <input type="text" name="address" /></td>

        <td>City & Zip:

  <br />

    <input type="text" name="city/zip" /></td>

        <td>Business Webpage:

  <br />

    <input type="text" name="webpage" /></td>

      </tr>

      <tr>

        <td>Main Category<br />

          <select name="Main Category">

          <option value="Food">Food</option>

    <option value="Soda">Soda</option>

          <option value="Candy">Candy</option>

          </select>

</td>

        <td>Sub Category:

  <br />

    <input type="text" name="category2" /></td>

        <td><p> </p></td>

      </tr>

      <tr>

      </table>

        <td><p>About the Business: <br />

          <textarea cols="88" rows="8" name="about"></textarea>

 

 

</h3>

        </p>

        <p><input type="submit" name="submit" value="Send" />

  <input type="reset" name="reset" value="Clear Form" /></p>

    </form>

 

 

 

.php file

 

 

<?php

 

 

/* Email Variables */

 

 

$emailSubject = 'Merchant Signup';

$webMaster = 'info@lf.com';

 

 

 

 

/* Data Variables */

 

 

$name = $_POST['name'];

$phone = $_POST['phone'];

$email = $_POST['email'];

$address = $_POST['address'];

$city = $_POST['city/zip'];

$webpage = $_POST['webpage'];

$main_category = $_POST['main'];

$category2 = $_POST['category2'];

$about = $_POST['about'];

$copy_photo[0]="";

 

 

 

 

 

 

$body = <<<EOD

<br><hr><br>

Name: $name <br>

Phone: $phone <br>

Email: $email <br>

Address: $address <br>

City: $city <br>

Wegpage: $webpage <br>

Main Category: $Main <br>

Category2: $category2 <br>

About: $about <br>

 

 

EOD;

$headers = "From: $email\r\n";

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

$success = mail($webMaster, $emailSubject, $body,

$headers);

 

 

 

 

/* Results rendered as HTML */

 

 

$theResults = <<<EOD

<html>

<head>

<title>sent message</title>

<meta http-equiv="refresh" content="3;URL=http://lf.com/index.shtml">

<style type="text/css">

<!--

body {

background-color: #000;

font-family: Verdana, Arial, Helvetica, sans-serif;

font-size: 20px;

font-style: normal;

line-height: normal;

font-weight: normal;

color: #FF0000;

text-decoration: none;

padding-top: 400px;

margin-left: 250px;

width: 800px;

}

 

 

 

 

-->

</style>

</head>

<div align="center"> Thank you for submitting your information! You will recieve an email from us shortly! </div>

</div>

</body>

</html>

EOD;

echo "$theResults";

?>

 

 

 

 

 

Any help would be greatly greatly appreciated!

 
Replies
  • Currently Being Moderated
    May 2, 2012 4:11 PM   in reply to jrandazzo1984

    Your form doesn't match your script.  Try to be consistent in your naming conventions.  Also, PHP is cAsE sEnSiTiVe so you need to pay attention to that as well.

     

    Change this in your form:

     

    <select name="Main Category">

     

    to this:

     

    <select name="main_category">

     

     

    And change this data variable in PHP:

     

    $main_category = $_POST['main'];

     

    to this:

     

    $main_category = $_POST['main_category'];

     

     

    It should work now.

     

     

     

    Nancy O.

    Alt-Web Design & Publishing

    Web | Graphics | Print | Media  Specialists 

    http://alt-web.com/

    http://twitter.com/altweb

    http://alt-web.blogspot.com/

     
    |
    Mark as:
  • Currently Being Moderated
    May 2, 2012 4:23 PM   in reply to jrandazzo1984

    Just to add to Nancy, in the $body EOD section, you also need to replace:

     

    Main Category: $Main <br>

     

    to match the new name

     

    Main Category: $main_category <br>

     
    |
    Mark as:
  • Currently Being Moderated
    May 2, 2012 4:36 PM   in reply to Rik Ramsay

    Good catch, Rik. 

     

     

    Nancy

     
    |
    Mark as:
  • Currently Being Moderated
    May 3, 2012 7:41 AM   in reply to jrandazzo1984

    It should be mentioned that there is no validation or sanitation of any of the form fields. A dot com and email are listed in the original post. Take some time and tighten up the security of this script. There are plenty of tutorials on the web.

     

    HTH

     

    -Rob B.

     
    |
    Mark as:
  • Currently Being Moderated
    May 4, 2012 10:32 PM   in reply to jrandazzo1984

    jrandazzo, I came on here looking for a script for my email form and I was wondering if I could use the one you posted above? I'm assuming its working with the doctype xhtml/1.0 transitional?

     

    The one I have every element is getting flagged as not valid with xhtml when I use the nifty code validator W3C Nancy posted.

     

    Nancy, in case you happen to see this and might can help me (again) my page is here:  http://www.healthquestpt.com/hpc/contact.html

     
    |
    Mark as:
  • Currently Being Moderated
    May 5, 2012 2:55 PM   in reply to BcSurvivor08

    I like this PHP script.  It has form validation, security and spam protection built-in.

    http://www.dbmasters.net/node/19

     

    This discussion details how to get it working with your HTML form:

    http://forums.adobe.com/thread/912801

     

     

     

    Nancy O.

    Alt-Web Design & Publishing

    Web | Graphics | Print | Media  Specialists 

    http://alt-web.com/

     
    |
    Mark as:
  • Currently Being Moderated
    May 6, 2012 10:19 AM   in reply to jrandazzo1984


    Thanks Nancy as always , you were a HUGE help!!

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points