Board index   FAQ   Search  
Register  Login
Board index PHP Your Scripts

calling drop down in php

This is where you share YOUR scripts with others

Moderators: macek, egami, gesf

calling drop down in php

Postby andyrichin » Wed May 04, 2011 12:22 pm

Hello. I am using a contact form on a site I am developing, and I am having problems getting the drop downs to work. There are actually two contact forms on the site, one just has text inputs, and this works fine. I receive it in my email and all is good. Here is the example: http://time4moore.com/booking_page2.html

The second form is giving me the problems. I need to add drop downs, but once I did it stopped working, primarily because I am not sure what to do with them in the php file. Here is the example that doesn't work: http://www.time4moore.com/employment_page.html

I think I have done all the HTML correctly, but now the PHP is the problem. Any help would be wonderful! Thanks.

HTML CODE: employment_page.html
Code: Select all
<!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=UTF-8" />
<title>Home of Lizette Moore // Booking</title>
<link href="styles.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="layout.css" ... />
<style>
   body {
      margin:0px;
      padding:0px;
      /*background-color:#600;
      background-image:url(lizette_bg.jpg);
      background-repeat:repeat-x;
      background-position:fixed;*/
   }
   #nav ul li {
      margin:0px;
   }
   
   td {
      color:#111;
      font-family:Century Gothic;
      font-size:12px;   
      padding:3px 0 3px 0;   
      
   }
   
   form {
      padding:0px;
   }
   
   form fieldset {
      border:1px solid #b51414;
   }
   
   form input, form textarea, form select {
      position:relative;
      left:-20px;
   }
</style>

<body id="employment-page">
<div class="wrapper">

<div id="nav_back">
<div id="nav_wrap">
<div id="nav">
<ul>
<li class="home"><a href="home_page.html">Home</a></li>
<li class="about"><a href="about_page.html">About</a></li>
<li class="gallery"><a href="gallery_page.html">Gallery</a></li>
<li class="booking"><a href="booking_page.html">Booking</a></li>
<li class="mooregirls"><a href="mooregirls_page.html">Moore Girls</a></li>
<li class="members"><a href="#">Members</a></li>
<li class="employment"><a href="#">Employment</a></li>
</ul>

</div>
</div>
</div>


<div id="lizetteHeader">
<div id="lizetteName">
<ul>
</ul>
</div>
</div>


<div id="employmentContent">

<div id="employmentMainContent">
<ul>
<h1>HIRE ME!</h1>
<p>Are you interested in become a Moore Girl? Tell me about yourself by filling out the form below and I'll see if you have what it takes! I will get back to you as soon as I can. Thanks! <strong>All fields are required.</strong></p>

<h2>Your Details</h2>

<form name="htmlform" method="post" action="employment_page.php">
<table width="650px">
</tr>
<tr>
 <td valign="top">
  <label for="name">Name *</label>
 </td>
 <td valign="top">
  <input  type="text" name="realname" maxlength="30" size="20">
 </td>
</tr>
<tr>
 <td valign="top">
  <label for="workname">Work Name *</label>
 </td>
 <td valign="top">
  <input  type="text" name="workname" maxlength="50" size="30">
 </td>
</tr>
<tr>
 <td valign="top">
  <label for="email">Email Address *</label>
 </td>
 <td valign="top">
  <input  type="text" name="email" maxlength="80" size="30">
 </td>
</tr>
<tr>
 <td valign="top">
  <label for="telephone">Phone Number *</label>
 </td>
 <td valign="top">
  <input  type="text" name="telephone" maxlength="30" size="20">
 </td>
</tr>
<tr>
 <td valign="top">
  <label for="age">Age *</label>
 </td>
 <td valign="top">
  <input  type="text" name="age" maxlength="30" size="5">
 </td>
</tr>
<tr>
 <td valign="top">
  <label for="eyecolor">Eye Color *</label>
 </td>
 <td valign="top">
  <input  type="text" name="eyecolor" maxlength="30" size="10">
 </td>
</tr>
<tr>
 <td valign="top">
  <label for="haircolor">Hair Color *</label>
 </td>
 <td valign="top">
  <input  type="text" name="haircolor" maxlength="30" size="10">
 </td>
</tr>
<tr>
<td valign="top">
  <label for="height">Height *</label>
</td>
<td valign="top">
  <select name="height">
  <option>Choose One</option>
  <option>> 5'</option>
  <option>5'1"</option>
  <option>5'2"</option>
  <option>5'3"</option>
  <option>5'4"</option>
  <option>5'5"</option>
  <option>5'6"</option>
  <option>5'7"</option>
  <option>5'8"</option>
  <option>5'9"</option>
  <option>5'10"</option>
  <option>5'11"</option>
  <option>6'</option>
  <option>6'1"</option>
  <option>6'2"</option>
  <option>6'3"</option>
  <option>< 6'4"</option>
  </select>
</td>
</tr>
<tr>
 <td valign="top">
  <label for="weight">Weight *</label>
 </td>
 <td valign="top">
  <input  type="text" name="weight" maxlength="30" size="10">
 </td>
</tr>
<tr>
 <td valign="top">
  <label for="stats">Statistics *</label>
 </td>
 <td valign="top">
  <input  type="text" name="stats" maxlength="30" size="30">
 </td>
</tr>
<tr>
 <td valign="top">
  <label for="nationality">Nationality *</label>
 </td>
 <td valign="top">
  <input  type="text" name="nationality" maxlength="30" size="30">
 </td>
</tr>
<tr><td></td>
</tr>
<tr>
 <td><h2>About You</h2></td>
</tr>
<tr>
<td valign="top">
  <label for="city">What city do you<br />want to be listed in? *</label>
 </td>
 <td valign="top">
  <input  type="text" name="city" maxlength="30" size="30">
 </td>
</tr>
<tr>
<td valign="top">
  <label for="incall">Do you have an<br />incall location? *</label>
 </td>
 <td valign="top">
  <select name="incall">
  <option>Choose One</option>
  <option>Yes</option>
  <option>No</option>
  </select>
 </td>
</tr>
<td valign="top">
  <label for="outcall">Do you have a<br />car for outcalls? *</label>
 </td>
 <td valign="top">
  <select name="incall">
  <option>Choose One</option>
  <option>Yes</option>
  <option>No</option>
  </select>
 </td>
</tr>

<tr>
<td valign="top">
  <label for="gps">Do you have a GPS? *</label>
</td>
<td valign="top">
  <select name="gps">
  <option>Choose One</option>
  <option>Yes</option>
  <option>No</option>
  </select>
</td>
</tr>

<tr>
<td valign="top">
  <label for="minprice">Minimum price you expect per hour *</label>
 </td>
 <td valign="top">
  <input  type="text" name="minprice" maxlength="30" size="30">
 </td>
</tr>

<tr>
<td valign="top">
  <label for="services">List any services offered *</label>
 </td>
 <td valign="top">
  <textarea name="services" maxlength="80" cols="25" rows="3"></textarea>
 </td>
</tr>

<tr>
<td valign="top">
  <label for="bisexual">Are you bisexual? *</label>
</td>
<td valign="top">
  <select name="bisexual">
  <option>Choose One</option>
  <option>Yes</option>
  <option>No</option>
  </select>
</td>
</tr>

<tr>
<td valign="top">
  <label for="website">Please include a link to reference photos *</label>
 </td>
 <td valign="top">
  <input  type="text" name="website" maxlength="40" size="40">
 </td>
</tr>

<tr>
 <td valign="top">
  <label for="comments">Comments *</label>
 </td>
 <td valign="top">
  <textarea  name="comments" maxlength="1000" cols="25" rows="6"></textarea>
 </td>

</tr>
<tr>
 <td colspan="2" style="text-align:left; padding-left:335px; padding-top:10px;">
  <!-- We are grateful to you for keeping this link in place. thank you. -->
  <input type="submit" value="Send Message">   
 </td>
</tr>
</table>
</form>


</ul>
</div>


</div>   


<div class="footer">
   <div id="foot_back">
      <div id="footer_wrap">
        <div id="footer_nav">
           <ul class="foot_top">
               <li><a href="home_page.html">Home</a></li>
                <li>|</li>
                <li><a href="about_page.html">About</a></li>
                <li>|</li>
                <li><a href="gallery_page.html">Gallery</a></li>
                <li>|</li>
                <li><a href="booking_page.html">Booking</a></li>
                <li>|</li>
                <li><a href="mooregirls_page.html">Moore Girls</a></li>
                <li>|</li>
                <li><a href="#">Members</a></li>
                <li>|</li>
                <li><a href="#">Employment</a></li>
            </ul>
            <ul class="foot_middle">
               <li><a href="member_page.html"><img src="images/member.png" alt="twitter" width="200" height="25" /></a></li>
                <li><a href="http://twitter.com/lotts_moore" target="_blank"><img src="images/twitter.png" alt="twitter" width="200" height="25" /></a></li>
            </ul>
            <ul class="foot_bottom">
               <li>Copyright © 2011 Lizette Moore. All Rights Reserved.</li>
             </ul>
        </div>
        </div>
    </div>
</div>
</div>
       
</body>



</html>



PHP CODE: employment_page.php
Code: Select all

<!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=UTF-8" />
<title>Home of Lizette Moore // Booking</title>
<link href="styles.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="../contactusform/layout.css" ... />
<SCRIPT TYPE="text/javascript" SRC="backlink.js"></SCRIPT>
<style>

<?php include ("styles.css"); ?>
   body {
      margin:0px;
      padding:0px;
      /*background-color:#600;
      background-image:url(lizette_bg.jpg);
      background-repeat:repeat-x;
      background-position:fixed;*/
   }
   #nav ul li {
      margin:0px;
   }
   .errormsg {
      font-family:Century Gothic;
      text-align:center;
      color:#111;
      font-size:150%;
      
   }
   
   #bookingMainConfirm p {
      font-family:Century Gothic;
      color:#111;
      font-size:14px;
      text-align:center;
   }
   
   #bookingMainConfirm a {
      font-family:Century Gothic;
      text-decoration:none;
      color:#b51414;
      font-weight:bold;
   }
   
   #bookingMainConfirm a:hover {
      color:#111;
      text-decoration:underline;
   }
</style>

<body id="booking-page">
<div class="wrapper">

<div id="nav_back">
<div id="nav_wrap">
<div id="nav">
<ul>
<li class="home"><a href="../contactusform/home_page.html">Home</a></li>
<li class="about"><a href="../contactusform/about_page.html">About</a></li>
<li class="gallery"><a href="../contactusform/gallery_page.html">Gallery</a></li>
<li class="booking"><a href="#">Booking</a></li>
<li class="mooregirls"><a href="../contactusform/mooregirls_page.html">Moore Girls</a></li>
<li class="members"><a href="#">Members</a></li>
<li class="employment"><a href="#">Employment</a></li>
</ul>

</div>
</div>
</div>


<div id="lizetteHeader">
<div id="lizetteName">
<ul>
</ul>
</div>
</div>


<div id="employmentContent">

<div id="employmentMainContent">
<ul>

<?php
if(isset($_POST['email'])) {
   
   // CHANGE THE TWO LINES BELOW
   $email_to = "andy.richin@gmail.com";
   
   $email_subject = "Employment";
   
   
   function died($error) {
      // your error code can go here
      echo '<p class="errormsg">';
      echo "We're sorry, but there's errors found with the form you submitted.<br /><br />";
      echo $error."<br /><br />";
      /*echo "<a href='booking_page2.html'>Please go back and fix these errors.</a><br /><br />";*/
      echo "<SCRIPT TYPE='text/javascript'>
<!--
var gb = new backlink();
gb.text = 'Please go back and fix these errors.';
gb.write();
//-->
</SCRIPT>";
      echo '</p>';
      die();
   }
   
   // validation expected data exists
   if(!isset($_POST['realname']) ||
      !isset($_POST['workname']) ||
      !isset($_POST['email']) ||
      !isset($_POST['telephone']) ||
      !isset($_POST['age']) ||
      !isset($_POST['eyecolor']) ||
      !isset($_POST['haircolor']) ||
      !isset($_POST['height']) ||
      !isset($_POST['weight']) ||
      !isset($_POST['stats']) ||
      !isset($_POST['nationality']) ||
      !isset($_POST['city']) ||
      !isset($_POST['incall']) ||
      !isset($_POST['outcall']) ||
      !isset($_POST['gps']) ||
      !isset($_POST['minprice']) ||
      !isset($_POST['services']) ||
      !isset($_POST['bisexual']) ||
      !isset($_POST['website']) ||
      !isset($_POST['comments'])) {
      died('We are sorry, but there appears to be a problem with the form you submitted.');      
   }
   
   $realname = $_POST['realname']; // required
   $workname = $_POST['workname']; // required
   $email_from = $_POST['email']; // required
   $telephone = $_POST['telephone']; // required
   $age = $_POST['age']; // required
   $eyecolor = $_POST['eyecolor']; // required
   $haircolor = $_POST['haircolor']; // required
   $height = $_POST['height']; // required
   $weight = $_POST['weight']; // required
   $stats = $_POST['stats']; // required
   $nationality = $_POST['nationality']; // required
   $city = $_POST['city']; // required
   $incall = $_POST['incall']; // required
   $outcall = $_POST['outcall']; // required
   $gps = $_POST['gps']; // required
   $minprice = $_POST['minprice']; // required
   $services = $_POST['services']; // required
   $bisexual = $_POST['bisexual']; // required
   $website = $_POST['website']; // required
   $comments = $_POST['comments']; // required
   
   $error_message = "";
   $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
  if(!preg_match($email_exp,$email_from)) {
     $error_message .= 'The Email Address you entered does not appear to be valid.<br />';
  }
   $string_exp = "/^[A-Za-z .'-]+$/";
  if(!preg_match($string_exp,$realname)) {
     $error_message .= 'The First Name you entered does not appear to be valid.<br />';
  }
   $string_exp = "/^[0-9 .'-]+$/";
  if(!preg_match($string_exp,$age)) {
     $error_message .= 'The Age you entered does not appear to be valid.<br />';
  }
     $string_exp = "/^[A-Za-z0-9.-]+$/";
  if(!preg_match($string_exp,$stats)) {
     $error_message .= 'The Statistics you entered does not appear to be valid.<br />';
  }
      $string_exp = "/^[A-Za-z0-9.-]+$/";
  if(!preg_match($string_exp,$website)) {
     $error_message .= 'The Website you entered does not appear to be valid.<br />';
  }
      $string_exp = "/^[0-9 .'-]+$/";
  if(!preg_match($string_exp,$weight)) {
     $error_message .= 'The Weight you entered does not appear to be valid.<br />';
  }
 
   $string_exp = "/^[0-9 .'-]+$/";
  if(!preg_match($string_exp,$telephone)) {
     $error_message .= 'The Phone Number you entered does not appear to be valid.<br />';
  }
     $string_exp = "/^[0-9 .'-]+$/";
  if(!preg_match($string_exp,$minprice)) {
     $error_message .= 'The Minimum price you entered does not appear to be valid.<br />';
  }
   $string_exp = "/^[A-Za-z .'-]+$/";         
  if(!preg_match($string_exp,$workname)) {
     $error_message .= 'The Last Name you entered does not appear to be valid.<br />';
  }
     $string_exp = "/^[A-Za-z .'-]+$/";         
  if(!preg_match($string_exp,$nationality)) {
     $error_message .= 'The Nationality you entered does not appear to be valid.<br />';
  }
   $string_exp = "/^[A-Za-z .'-]+$/";
  if(!preg_match($string_exp,$city)) {
     $error_message .= 'The Listing city you entered does not appear to be valid.<br />';
  }
   
     $string_exp = "/^[A-Za-z .'-]+$/";
  if(!preg_match($string_exp,$eyecolor)) {
     $error_message .= 'The Eye color you entered does not appear to be valid.<br />';
  }
     $string_exp = "/^[A-Za-z .'-]+$/";
  if(!preg_match($string_exp,$haircolor)) {
     $error_message .= 'The Hair color you entered does not appear to be valid.<br />';
  }
  if(strlen($comments) < 2) {
     $error_message .= 'The Comments you entered do not appear to be valid.<br />';
  }
  if(strlen($services) < 2) {
     $error_message .= 'The Services you entered does not appear to be valid.<br />';
  }
  if(strlen($error_message) > 0) {
     died($error_message);
  }
   $email_message = "Form details below.\n\n";
   
   function clean_string($string) {
     $bad = array("content-type","bcc:","to:","cc:","href");
     return str_replace($bad,"",$string);
   }
   
   $email_message .= "First Name: ".clean_string($first_name)."\n";
   $email_message .= "Last Name: ".clean_string($last_name)."\n";
   $email_message .= "Email: ".clean_string($email_from)."\n";
   $email_message .= "Phone Number: ".clean_string($telephone)."\n";
   $email_message .= "Age: ".clean_string($age)."\n";
   $email_message .= "Eye Color: ".clean_string($eyecolor)."\n";
   $email_message .= "Hair Color: ".clean_string($haircolor)."\n";
   $email_message .= "Height: ".clean_string($height)."\n";
   $email_message .= "Weight: ".clean_string($weight)."\n";
   $email_message .= "Statistics: ".clean_string($stats)."\n";
   $email_message .= "Nationality: ".clean_string($nationality)."\n";
   $email_message .= "City you want to be listed in: ".clean_string($city)."\n";
   $email_message .= "Incall Location: ".clean_string($incall)."\n";
   $email_message .= "Transportation for Outcalls: ".clean_string($outcall)."\n";
   $email_message .= "GPS: ".clean_string($gps)."\n";
   $email_message .= "Minimum price per hour: ".clean_string($minprice)."\n";
   $email_message .= "Services offered: ".clean_string($services)."\n";
   $email_message .= "Bisexual: ".clean_string($bisexual)."\n";
   $email_message .= "Website: ".clean_string($website)."\n";
   $email_message .= "Comments: ".clean_string($comments)."\n";
   
   
// create email headers
$headers = 'From: '.$email_from. "\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers); 
?>

<!-- place your own success html below -->

<center><p>Thank you for contacting me. I will be in touch with you very soon.<br /><br /><a href="booking_page.html"><b>Return to Booking Page</b></a></p></center>

<?php
}
die();
?>

</ul>
</div>


</div>   


<div class="footer">
   <div id="foot_back">
      <div id="footer_wrap">
        <div id="footer_nav">
           <ul class="foot_top">
               <li><a href="home_page.html">Home</a></li>
                <li>|</li>
                <li><a href="about_page.html">About</a></li>
                <li>|</li>
                <li><a href="gallery_page.html">Gallery</a></li>
                <li>|</li>
                <li><a href="#">Booking</a></li>
                <li>|</li>
                <li><a href="mooregirls_page.html">Moore Girls</a></li>
                <li>|</li>
                <li><a href="#">Members</a></li>
                <li>|</li>
                <li><a href="#">Employment</a></li>
            </ul>
            <ul class="foot_middle">
               <li><a href="member_page.html"><img src="images/member.png" alt="twitter" width="200" height="25" /></a></li>
                <li><a href="http://twitter.com/lotts_moore" target="_blank"><img src="images/twitter.png" alt="twitter" width="200" height="25" /></a></li>
            </ul>
            <ul class="foot_bottom">
               <li>Copyright © 2011 Lizette Moore. All Rights Reserved.</li>
             </ul>
        </div>
        </div>
    </div>
</div>
</div>
       
</body>



</html>
andyrichin
New php-forum User
New php-forum User
 
Posts: 22
Joined: Fri Apr 29, 2011 5:02 pm

Return to Your Scripts

Who is online

Users browsing this forum: Baidu [Spider] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.