Jump to content

Simple Form


pina

Recommended Posts

On my website i have a form for customers to get in touch with me. This forum points to a php script to email me and tell them it has been submitted(via html). Here is the forum and the php script.

 

Form from html file

<form id="supportform" name="Support Form" method="post" action="php/formemail.php">
      <table width="100%" border="0">
        <tr>
          <td width="22%">Name:</td>
          <td width="78%"><input type="text" name="name" id="name" /></td>
        </tr>
        <tr>
          <td>Email:</td>
          <td><input type="text" name="email" id="email" /></td>
        </tr>
        <tr>
          <td>Company:</td>
          <td><input type="text" name="company" id="company" /></td>
        </tr>
        <tr>
          <td>Phone:</td>
          <td><input type="text" name="phone" id="phone" /></td>
        </tr>
        <tr>
          <td>Operating System:</td>
          <td><input type="text" name="os" id="os" /></td>
        </tr>
        <tr>
          <td>What Do You Need Help With?</td>
          <td><input type="text" name="problem" id="problem" /></td>
        </tr>
        <tr>
          <td>Additional Clarification:</td>
          <td><textarea name="additional" id="additional" cols="45" rows="3"></textarea></td>
        </tr>
        <tr>
          <td>Contact Preference:</td>
          <td><select name="preference" id="preference">
            <option value="null">Please Select</option>
            <option value="phone">Phone</option>
            <option value="email">Email</option>
          </select></td>
        </tr>
        <tr>
          <td>How Did You Hear Of Us?</td>
          <td><select name="advert" id="advert">
            <option value="null">Please Select</option>
            <option value="radio">Radio</option>
            <option value="newspaper">Newspaper</option>
            <option value="other">Other</option>
          </select></td>
        </tr>
        <tr>
          <td><input type="submit" name="Submit" id="submit" value="Submit" style="width:100px;height:30px" />
          <input type="reset" name="reset" id="reset" value="Reset" style="width:62px;height:30px;" /></td>
          <td> </td>
        </tr>
      </table>
    </form>

 

Here is php script

<?PHP

/*Subject an email variables */

$emailSubject = 'PHP Email Script';
$webMaster = 'me@mysite;otherperson@gmail.com';

/* Gathering Data Variables */

$nameField = $_POST['name'];
$emailField = $_POST['email'];
$companyField = $_POST['company'];
$phoneField = $_POST['phone'];
$osField = $_POST['os'];
$problemField = $_POST['problem'];
$additionalField = $_POST['additional'];
$preferenceField = $_POST['preference'];
$advertField = $_POST['advert'];

$body = <<<EOD
<br><hr><br>
Name: $nameField <br>
Email: $emailField <br>
Company: $companyField <br>
Phone: $phoneField <br>
OS: $osField <br>
Problem: $problemField <br>
Additional Info: $additionalField <br>
Preference: $preferenceField <br>
Advertising: $advertField <br>
<br>
Have a nice day!
EOD;

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

/* Results rendered as HTML */

$theResults = <<<EOD
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Title</title>
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon" />
<link href="css.css" rel="stylesheet" type="text/css">
<style type="text/css">
body {
background-color: #FFF;
}
</style>
</head>
<body>
  <div class="header"><a href="#"><img src="" alt="" name="greenhead" width="100%" height="17" id="greenhead" style="background: #B1FB17; display:block;" /></a> 
    <!-- end .header --></div>
  <div class="content">
    <h1> </h1>
    <h1><img src="/images/logo2.jpg" width="194" height="152" align="middle"> Tech Suppport MT</h1>
    <h1 align="center">Success!</h1>
    <h2 align="center">Your information has been submitted to us.</h2>
    <p align="center"> </p>
    <p align="center"><a href="/index.html">index - Home</a></p>
    <p> </p>
    <p> </p>
    <p> </p>
  </div>
  <div class="footer">
    <h4 align="center">footer</h4>
    <!-- end .footer --></div>
  <!-- end .container -->
</body>
</html>
EOD;

echo "$theResults";

?>

 

Everything works as it should except both people are getting two emails. One email with everything correct and the correct results. And another with all null values from an unknown sender. I should not be receiving one from an unknown sender with empty values.

 

Thanks for any help.

Link to comment
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.