I am creating a basic html "contact us" form using php to send the data securely via email.
I posted the form and the screen turns blank when I hit the "submit" button.
Server is running PHP 5.2 with Mysql 5 and Apache 2
Viewing the page with Mozilla Firefox Browser 2.0
Site is wrapped in a custom tailored CMS based on Cake
Code is below...
sendmail.php code...
Expand|Select|Wrap|Line Numbers
- <?php
- if (isset($_POST['submitted'])) {
- $errors = array();
- if (empty($_POST['name'])) {
- $errors[] = 'You did not enter your name.';
- }
- else {
- $name = $_POST['name'];
- }
- if (empty($_POST['email'])) {
- $errors[] = 'You did not enter an email address.';
- }
- else {
- $email = $_POST['email'];
- }
- if (empty($_POST['company'])) {
- $errors[] = 'You enter company name.';
- }
- else {
- $company = $_POST['company'];
- }
- if (empty($_POST['title'])) {
- $errors[] = 'You did not enter a title.';
- }
- else {
- $title = $_POST['title'];
- }
- if (empty($_POST['phone'])) {
- $errors[] = 'You did not your phone number.';
- }
- else {
- $phone = $_POST['phone'];
- }
- if (empty($_POST['projname'])) {
- $errors[] = 'You did not enter your project name.';
- }
- else {
- $projname = $_POST['projname'];
- }
- if (empty($_POST['projectpurp'])) {
- $errors[] = 'You did not enter your project\'s purpose.';
- }
- else {
- $projectpurp = $_POST['projectpurp'];
- }
- if (empty($_POST['operatingsys'])) {
- $errors[] = 'You did not enter operating system.';
- }
- else {
- $operatingsys = $_POST['operatingsys'];
- }
- if (empty($_POST['projdescript'])) {
- $errors[] = 'You did not enter a proj description.';
- }
- else {
- $projdescript = $_POST['projdescript'];
- }
- if (empty($_POST['howfindsite'])) {
- $errors[] = 'You did not enter how you found our site.';
- }
- else {
- $howfindsite = $_POST['howfindsite'];
- }
- if (empty($_POST['deploytimeframe'])) {
- $errors[] = 'You did not enter a deployment timeframe.';
- }
- else {
- $deploytimeframe= $_POST['deploytimeframe'];
- }
- if (empty($errors)) { // No errors happened
- $emailmessage = "The following customer inquiry was made:\n
- $name\n$email\n$company\n$title\n$phone\n$projname\n$projpurpurp\n$operatingsys\n$projdescript\n$howfindsite\n$deploytimeframe";
- mail( "name@name.com, name12@name.com", "Identifinder Customer Inquiry",
- "$emailmessage", "From: $email" );
- header( "Location: /identifinder_contact_us/identifinder_contact_form_thank_you" );
- }
- else {
- foreach ($errors as $msg) {
- echo '<li> '.$msg.'</li>';
- }
- }
- }
- ?>
Expand|Select|Wrap|Line Numbers
- <!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=iso-8859-1" />
- <title>Untitled Document</title>
- </head>
- <body>
- <div class="textWrap">
- <h4><span class="highlight">Thank you</span> for your interest in Name Technologies.</h4>
- <h6>We will be in touch with you shortly.</h6>
- <form method="POST" action="/php/sendmail.php">
- <table border="0" cellpadding="0" cellspacing="0">
- <tr>
- <td>
- <p class="formlisting">Name: </p> </td>
- <td>
- <input type="text" name="name" value="" size="40" maxlength="64" autocomplete="off" /> </td>
- </tr>
- <tr>
- <td>
- <p class="formlisting">E-mail: </p> </td>
- <td>
- <input type="text" name="email" value="" size="40" maxlength="64" autocomplete="off" /> </td>
- </tr>
- <tr>
- <td>
- <p class="formlisting">Company: </p> </td>
- <td>
- <input type="text" name="company" value="" size="40" maxlength="64" autocomplete="off" /> </td>
- </tr>
- <tr>
- <td>
- <p class="formlisting">Job Title: </p> </td>
- <td>
- <input type="text" name="title" value="" size="40" maxlength="64" autocomplete="off" /> </td>
- </tr>
- <tr>
- <td>
- <p class="formlisting">Phone: </p> </td>
- <td>
- <input type="text" name="phone" value="" size="40" maxlength="40" autocomplete="off" /> </td>
- </tr>
- <tr>
- <td>
- <p class="formlisting">Project Name: </p> </td>
- <td>
- <input type="text" name="projname" value="" size="40" maxlength="40" autocomplete="off" /> </td>
- </tr>
- <tr>
- <td>
- <p class="formlisting">Project Purpose: </p> </td>
- <td><select name="projectpurp">
- <option value=""> </option>
- <option value="SEARCH">Internal company prototype</option>
- <option value="WRDMTH">Research - Academic</option>
- <option value="MAGADV">Research - Commercial</option>
- <option value="OTHER">Other - Enter Purpose</option>
- </select></td>
- </tr>
- </p>
- <tr>
- <td>
- <p class="formlisting">Operating System: </p> </td>
- <td>
- <select name="operatingsys">
- <option value=""> </option>
- <option value="SEARCH">Windows XP</option>
- <option value="WRDMTH">2003</option>
- <option value="MAGADV">Linux</option>
- <option value="OTHER">Other</option>
- </select> </td>
- </tr>
- </table>
- <p class="formlisting"><br />Please type a few sentences describing the nature of your project</p>
- <p class="formlisting"><textarea name="projdescript" rows="4" cols="54" wrap="virtual"></textarea></p>
- <p class="formlisting">You found our site via:</p>
- <p class="formlisting">
- <select name="howfindsite">
- <option value=""> </option>
- <option value="SEARCH">Search engine</option>
- <option value="WRDMTH">Word of mouth</option>
- <option value="MAGADV">Magazine advertisement</option>
- <option value="TRDCNF">Trade show/Conference</option>
- <option value="OTHER">Other</option>
- </select>
- </p>
- <p class="formlisting">If a commercial entity, how long until you hope to deploy IdentiFinder commercially?</p>
- <p class="formlisting">
- <select name="deploytimeframe">
- <option value=""> </option>
- <option value="NOT">not commercial entity</option>
- <option value="3">3 months</option>
- <option value="6">6months</option>
- <option value="1">1 year</option>
- <option value="unk">unknown</option>
- </select>
- </p>
- <p style="text-align: center;"><input type="submit" value="Submit" /></p>
- </form>
- </div>
- </body>
- </html>