Sponsored By

Sign in to follow this  
bogointeractive

Code/Form HTML Help Needed

Recommended Posts

OK I am in the process of creating this online form and I have the form the way I want it with this code.

<form name="contactform" method="post" action="send_form_email.php"> 
<table>

<tr>
<td valign="top">
<font size="1">First Name *</font>
</td>
<td valign="top">
<input class="emailbox" type="text" name="first_name" maxlength="50" size="30" />
</td>
</tr>

<tr>
<td valign="top">
<font size="1">Last Name: *</font>
</td>
<td valign="top">
<input class="emailbox" type="text" name="last_name" maxlength="50" size="30" />
</td>
</tr>
<tr>
<td valign="top">
<font size="1">Email Address: *</font>
</td>
<td valign="top">
<input class="emailbox" type="text" name="email" maxlength="80" size="30" />
</td>
</tr>
<tr>
<td valign="top">
<font size="1">Phone Number: *</font>
</td>
<td valign="top">
<input class="emailbox" type="text" name="phone" maxlength="10" size="30" />
</td>
</tr>
<tr>
<td valign="top">
<font size="1">Party Type: *</font>
</td>
<td valign="top">
<select name="PartyType" class="menu">
<option value="Select a Type...">Select a Type...</option>
<option value="Anniversary">Anniversary</option>
<option value="Bachelor Party">Bachelor Party</option>
<option value="Bachelorette Party">Bachelorette Party</option>
<option value="Birthday Party">Birthday Party</option>
<option value="Business or Corporate Meeting">Business/Corporate Meeting</option>
<option value="Cocktail">Cocktail Hour</option>
<option value="Golf Outing">Golf Outing</option>
<option value="Happy Hour">Happy Hour</option>
<option value="Holiday">Holiday</option>
<option value="Office Party">Office Party</option>
<option value="Other">Other</option>
<option value="Promotional">Promotional Event</option>
<option value="Reunion">Reunion</option>
<option value="Sitdown">Sitdown Dinner</option>
</select>
</td>
</tr>
<tr>
<td valign="top">
<font size="1">Desired Date: *</font>
</td>
<td valign="top">
<select name="PartyMonth" class="dropdownmenu">
<option value="1">Month</option>
<option value="1">January</option>
<option value="2">February</option>
<option value="3">March</option>
<option value="4">April</option>
<option value="5">May</option>
<option value="6">June</option>
<option value="7">July</option>
<option value="8">August</option>
<option value="9">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12">December</option>
</select>
<select name="PartyDay" class="dropdownmenu">
<option value="1">Day</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select>
<select name="PartyYear" class="dropdownmenu">
<option value="1900">Year</option>
<option value="2008">2011</option>
<option value="2009">2012</option>
<option value="2010">2013</option>
</select>
</td>
</tr>
<tr>
<td valign="top">
<font size="1">Desired Time: *</font>
</td>
<td valign="top">
<input class="emailbox" type="text" name="time" maxlength="10" size="30" />
</td>
</tr>
<tr>
<td valign="top">
<font size="1">Comments: *</font>
</td>
<td valign="top">
<textarea name="Comments" rows="5" class="box" cols="24"></textarea>
</td>
</tr>
<tr>
<td colspan="2" style="text-align:center">
<input name="Submit" type="submit" class="orangebox" value="SUBMIT" /></td>
</tr>
</table>
</form>

but the page that it gets sent to to validate form is needing some work. I need to have it accept and validate all the information from this form. Here is the code from that page.

<?php
if(isset($_POST['email'])) {

// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = " [email protected]";
$email_subject = "Event Signup Form";


function died($error) {
// your error code can go here
echo "We are very sorry, but there were error(s) found with the form your submitted. ";
echo "These errors appear below.<br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}

// validation expected data exists
if(!isset($_POST['first_name']) ||
!isset($_POST['last_name']) ||
!isset($_POST['email'])


) {
died('We are sorry, but there appears to be a problem with the form your submitted.');
}

$first_name = $_POST['first_name']; // required
$last_name = $_POST['last_name']; // required
$email_from = $_POST['email']; // required

$error_message = "";
$email_exp = "^[A-Z0-9._%-][email protected][A-Z0-9.-]+\.[A-Z]{2,4}$";
if(!eregi($email_exp,$email_from)) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
}
$string_exp = "^[a-z .'-]+$";
if(!eregi($string_exp,$first_name)) {
$error_message .= 'The First Name you entered does not appear to be valid.<br />';
}
if(!eregi($string_exp,$last_name)) {
$error_message .= 'The Last Name 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";

// 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);
?>

Thank you for contacting us. We will be in touch with you very soon.

<?php
}
?>

so what do I need to fix here. Please help

Share this post


Link to post
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
Sign in to follow this