Revision: 11919
                            
                                                            
                                    
                                        
Updated Code
                                    
                                    
                                                    
                        at February 25, 2009 19:42 by jadedbat
                            
                            Updated Code
CSS
<style type="text/css">  #botty {display:none;} <style>
Javascript
<script type="text/javascript">
function checkform(form){
// check first name
if (form.FirstName.value == "") {
alert( "Please enter your First Name." );
form.FirstName.focus();
return false ;
}
// check last name
if (form.LastName.value == "") {
alert( "Please enter your Last Name." );
form.LastName.focus();
return false ;
}
// check email field
if (form.email.value == "") {
alert( "Please enter your Email Address." );
form.email.focus();
return false ;
}
// check for valid email addy
var apos=form.email.value.indexOf("@");
var dotpos=form.email.value.lastIndexOf(".");
if (apos<1||dotpos-apos<2){
alert("Not A Valid Email Address!");
return false;
}
// ** END **
return true ;
}
</script>
HTML
<form action="contact_handle.php" method="post" name="formy" id="formy">
<p>* Required</p>
<table cellspacing="0" cellpadding="2" border="0" class="webform">
<tbody>
<tr>
<td><label for="Title">Title</label>
<br />
<select name="Title" id="Title" class="cat_dropdown_smaller">
<option value="126631">DR</option>
<option value="126629">MISS</option>
<option value="126627" selected="selected">MR</option>
<option value="126628">MRS</option>
<option value="126630">MS</option>
</select></td>
</tr>
<tr>
<td><label for="FirstName">First Name</label>
<br />
<input name="FirstName" type="text" class="cat_textbox" id="FirstName" size="35" maxlength="255" />
*</td>
</tr>
<tr>
<td><label for="LastName">Last Name</label>
<br />
<input name="LastName" type="text" class="cat_textbox" id="LastName" size="35" maxlength="255" />
*</td>
</tr>
<tr>
<td><label for="email">Email Address</label>
<br />
<input name="email" type="text" class="cat_textbox" id="email" size="35" maxlength="255" />
*</td>
</tr>
<tr>
<td><label for="comments">Comments/Enquiries</label>
<br />
<textarea name="comments" cols="45" rows="8" class="cat_listbox" id="comments" onkeydown="if(this.value.length>=1024)this.value=this.value.substring(0,1023);"></textarea></td>
</tr>
<tr>
<td><input name="subscribe" type="checkbox" id="subscribe" value="yes" />
Subscribe to: Email List Signup</td>
</tr>
<tr>
<td><input type="submit" class="cat_button" value="Submit" id="catwebformbutton" />
<span id="formHide"><input type="text" id="botty" name="botty" /></span>
</td>
</tr>
</tbody>
</table>
</form>
PHP
<?php
//form data
$FirstName = strip_tags($_POST['FirstName']);
$LastName = strip_tags($_POST['LastName']);
$email = strip_tags($_POST['email']);
$subscribe = strip_tags($_POST['subscribe']);
$comments = strip_tags($_POST['comments']);
// prove if a bot has entered data
$botty = strip_tags($_POST['botty']);
if($botty != NULL){
echo "barghh! darn bot!";
die;
}
// the email address where the script will email the form results to
$to = "[email protected]";
// where the email will look like it is sent from
$from = "[email protected]";
$subject = "Email from your website";
$body = "Email from your website" . "
 
";
$body .= "Name: " . $FirstName . $LastName . "
";
$body .= "Email: " . $email . "
";
$body .= "Newsletter: " . $subscribe . "
";
$body .= "Comments: " . $comments . "
";
$headers = "From: $from" . "
";
$headers .= "Reply-To: $from" . "
";
$headers .= "Return-Path: $from" . "
";
// mail(to,subject,body,headers); 
$isMailed = mail($to, $subject, $body, $headers);
if($isMailed){
echo "Thank you for your inquery, " . $FirstName . " " . $LastName . " We will get back to you shortly.";
}else{
echo "There seemed to be a problem";
}
?>
                                
                            Revision: 11918
                            
                                                            
                                    
                                        
Initial Code
                                    
                                    
                                                            
                                    
                                        
Initial URL
                                    
                                    
                                                            
                                    
                                        
Initial Description
                                    
                                    
                                                            
                                    
                                        
Initial Title
                                    
                                    
                                                            
                                    
                                        
Initial Tags
                                    
                                    
                                                            
                                    
                                        
Initial Language
                                    
                                    
                                                    
                        at February 23, 2009 20:20 by jadedbat
                            
                            Initial Code
CSS
<style type="text/css">  #botty {display:none;} <style>
HTML
<form action="contact_handle.php" method="post" name="formy" id="formy">
<p>* Required</p>
<table cellspacing="0" cellpadding="2" border="0" class="webform">
<tbody>
<tr>
<td><label for="Title">Title</label>
<br />
<select name="Title" id="Title" class="cat_dropdown_smaller">
<option value="126631">DR</option>
<option value="126629">MISS</option>
<option value="126627" selected="selected">MR</option>
<option value="126628">MRS</option>
<option value="126630">MS</option>
</select></td>
</tr>
<tr>
<td><label for="FirstName">First Name</label>
<br />
<input name="FirstName" type="text" class="cat_textbox" id="FirstName" size="35" maxlength="255" />
*</td>
</tr>
<tr>
<td><label for="LastName">Last Name</label>
<br />
<input name="LastName" type="text" class="cat_textbox" id="LastName" size="35" maxlength="255" />
*</td>
</tr>
<tr>
<td><label for="email">Email Address</label>
<br />
<input name="email" type="text" class="cat_textbox" id="email" size="35" maxlength="255" />
*</td>
</tr>
<tr>
<td><label for="comments">Comments/Enquiries</label>
<br />
<textarea name="comments" cols="45" rows="8" class="cat_listbox" id="comments" onkeydown="if(this.value.length>=1024)this.value=this.value.substring(0,1023);"></textarea></td>
</tr>
<tr>
<td><input name="subscribe" type="checkbox" id="subscribe" value="yes" />
Subscribe to: Email List Signup</td>
</tr>
<tr>
<td><input type="submit" class="cat_button" value="Submit" id="catwebformbutton" />
<span id="formHide"><input type="text" id="botty" name="botty" /></span>
</td>
</tr>
</tbody>
</table>
</form>
##php##
  <?php
//form data
$FirstName = strip_tags($_POST['FirstName']);
$LastName = strip_tags($_POST['LastName']);
$email = strip_tags($_POST['email']);
$subscribe = strip_tags($_POST['subscribe']);
$comments = strip_tags($_POST['comments']);
// prove if a bot has entered data
$botty = strip_tags($_POST['botty']);
if($botty != NULL){
echo "barghh! darn bot!";
die;
}
// the email address where the script will email the form results to
$to = "[email protected]";
// where the email will look like it is sent from
$from = "[email protected]";
$subject = "Email from your website";
$body = "Email from your website" . "
 
";
$body .= "Name: " . $FirstName . $LastName . "
";
$body .= "Email: " . $email . "
";
$body .= "Newsletter: " . $subscribe . "
";
$body .= "Comments: " . $comments . "
";
$headers = "From: $from" . "
";
$headers .= "Reply-To: $from" . "
";
$headers .= "Return-Path: $from" . "
";
// mail(to,subject,body,headers); 
$isMailed = mail($to, $subject, $body, $headers);
if($isMailed){
echo "Thank you for your inquery, " . $FirstName . " " . $LastName . " We will get back to you shortly.";
}else{
echo "There seemed to be a problem";
}
?>
                                Initial URL
http://www.thatgrafix.com
Initial Description
A simple to use framework for a contact form. This is missing some serious validation and such but is a good startin' point for any simple contact form. The input field named 'botty' is an input field we hide with css.. if data is sent to the handling file from that field then we know a non-human filled this form out.. and it kills the script. ** just added some simple jscript to handle some mild validation.
Initial Title
Simple PHP Contact Form + jscript validation + anti-bot
Initial Tags
form, php, html
Initial Language
PHP