Skip navigation
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 action="merchantsignup.php" method="post" id="contact_form">

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


        <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>



        <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>



        <td>Main Category<br />

          <select name="Main Category">

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

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

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



        <td>Sub Category:

  <br />

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

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




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

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





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

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





.php file






/* Email Variables */



$emailSubject = 'Merchant Signup';

$webMaster = '';





/* 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'];








$body = <<<EOD


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>




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

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

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






/* Results rendered as HTML */



$theResults = <<<EOD



<title>sent message</title>

<meta http-equiv="refresh" content="3;URL=">

<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;









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





echo "$theResults";







Any help would be greatly greatly appreciated!

  • 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

    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. 




    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.




    -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:

    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.


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




    Nancy O.

    Alt-Web Design & Publishing

    Web | Graphics | Print | Media  Specialists

    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