http://www.elated.com/articles/slick-ajax-contact-form-jquery-php/
This tutorial shows you how to build a nice-looking, smooth contact form that visitors can use without having to leave the page they're reading.
|

/^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/
if ( !$('#fieldName').val().match( /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/ ) ) {
// invalid
}



header( "Content-type: image/png" );


<div id="info">This text will be replaced after form submission.</div>
if ( isset($_GET["ajax"]) ) {
echo $success ? "success" : "error";
if ( isset($_GET["ajax"]) ) {
echo $success ? "success|$file_link" : "error";
response = $.trim( response );
var result = response.split("|");
var success_resp = $.trim( result[0] );
var new_info = $.trim( result[1] );
if ( response == "success" ) {
if ( success_resp == "success" ) {
$('#content').delay(messageDelay+500).fadeTo( 'slow', 1 );
$('#info').replaceWith(new_info);
<article id="contact">
<form action="process_form.php" method="post" id="contact_form">
<h2>お問合せ</h2>
<div id="cancel">閉じる</div>
<fieldset>
<label for="name">お名前</label>
<label for="name" class="error" generated="true"></label>
<input type="text" name="name" class="form_input required" id="name" size="50" />
<label for="phone">電話番号</label>
<label for="phone" class="error" generated="true"></label>
<input type="text" name="phone" class="form_input required" id="phone" size="50" />
<label for="email">メールアドレス</label>
<label for="email" class="error" generated="true"></label>
<input type="text" name="email" class="form_input required email" id="email" size="50" />
</fieldset>
<fieldset>
<label for="message">ご要望</label>
<label for="message" class="error" generated="true"></label>
<textarea name="message" rows="5" class="required" id="message"></textarea>
</fieldset>
<fieldset>
<input type="submit" name="submit" value="送信" class="contact_button" />
</fieldset>
</form>
<div id="sending-message" class="status-message">
<p>お問合せの内容は貴方宛に送信しています。しばらくお待ち下さい。</p>
</div>
<div id="success-message" class="status-message">
<p><strong>ありがとうございました!</strong> お問合せの内容は貴方宛に送信致しました。後ほど改めて詳細をメール致します。</p>
</div>
<div id="failure-message" class="status-message">
<p><strong>エラーがありました!</strong> もい一度内容を入力して下さい。</p>
</div>
<div id="incomplete-message" class="status-message">
<p>全てのフィールドは必須です。</p>
</div>
</article>
<script>
var messageDelay = 2000;
$( init );
function init() {
$('#contact_form').hide().submit( submitForm ).addClass( 'positioned' );
$('a[href="#contact_form"]').click( function() {
$('#page-wrapper').fadeTo( 'slow', .2 );
$('#contact_form').fadeIn( 'slow', function() {
$('#name').focus();
} )
return false;
} );
$('#cancel').click( function() {
$('#contact_form').fadeOut();
$('#page-wrapper').fadeTo( 'slow', 1 );
} );
$('#contact_form').keydown( function( event ) {
if ( event.which == 27 ) {
$('#contact_form').fadeOut();
$('#page-wrapper').fadeTo( 'slow', 1 );
}
} );
}
function submitForm() {
var contact_form = $(this);
if ( !$('#name').val() || !$('#phone').val() || !$('#email').val() || !$('#message').val() ) {
$('#incomplete-message').fadeIn().delay(messageDelay).fadeOut();
contact_form.fadeOut().delay(messageDelay).fadeIn();
}
else {
$('#sending-message').fadeIn();
contact_form.fadeOut();
$.ajax( {
url: contact_form.attr( 'action' ) + "?ajax=true",
type: contact_form.attr( 'method' ),
data: contact_form.serialize(),
success: submitFinished
} );
}
return false;
}
function submitFinished( response ) {
response = $.trim( response );
$('#sending-message').fadeOut();
if ( response == "success" ) {
$('#success-message').fadeIn().delay(messageDelay).fadeOut();
$('#name').val( "" );
$('#phone').val( "" );
$('#email').val( "" );
$('#message').val( "" );
$('#page-wrapper').delay(messageDelay+500).fadeTo( 'slow', 1 );
}
else {
$('#failure-message').fadeIn().delay(messageDelay).fadeOut();
$('#contact_form').delay(messageDelay+500).fadeIn();
}
}
</script>
<?php
// Define some constants
define( "RECIPIENT_NAME", "JPB泉南" );
define( "RECIPIENT_EMAIL", "ruiz@junctionproduce-boutique.jp" );
define( "EMAIL_SUBJECT", "お問合せ" );
// Read the form values
$success = false;
$name = isset( $_POST['name'] ) ? preg_replace( "/[^\.\-\' a-zA-Z0-9]/", "", $_POST['name'] ) : "";
$phone = isset( $_POST['phone'] ) ? preg_replace( "/[^\.\-\' a-zA-Z0-9]/", "", $_POST['phone'] ) : "";
$email = isset( $_POST['email'] ) ? preg_replace( "/[^\.\-\_\@a-zA-Z0-9]/", "", $_POST['email'] ) : "";
$message = isset( $_POST['message'] ) ? preg_replace( "/(From:|To:|BCC:|CC:|Subject:|Content-Type:)/", "", $_POST['message'] ) : "";
// If all values exist, send the email
if ( $name && $phone && $email && $message ) {
$recipient = RECIPIENT_NAME . " <" . RECIPIENT_EMAIL . ">";
$headers = "From: " . $name . " <" . $email . ">";
$success = mail( $recipient, EMAIL_SUBJECT, $message, $headers );
}
// Return an appropriate response to the browser
if ( isset($_GET["ajax"]) ) {
echo $success ? "success" : "error";
} else {
?>
<html>
<head>
<title>お問合せ</title>
</head>
<body>
<?php if ( $success ) echo "<p><strong>ありがとうございました!</strong> お問合せの内容は貴方宛に送信致しました。後ほど改めて詳細をメール致します。</p>" ?>
<?php if ( !$success ) echo "<p><strong>エラーがありました!</strong> もい一度内容を入力して下さい。</p>" ?>
<p>ブラウザーの「戻る」ボタンを押して下さい。</p>
</body>
</html>
<?php
}
?>
http://pear.php.net/manual/en/installation.checking.php
http://www.phpmaniac.net/wiki/index.php/Pear_Mail

<form id="contactForm" name="contact" action="processForm.php" method="post">
<div class="contact-name">
<label id="senderName_label">Your Name</label>
<input type="text" name="senderName" id="senderName" placeholder="Please type your name" required="required" maxlength="30" />
</div>
<div class="contact-email">
<label id="senderEmail_label">Your Email</label>
<input type="email" name="senderEmail" id="senderEmail" placeholder="Please type your email address" required="required" maxlength="30" />
</div>
<div class="contact-message">
<label id="senderMessage_label">Your Message</label>
<textarea name="message" id="message" placeholder="Please type your message" required="required" cols="80" rows="10" maxlength="10000"></textarea>
</div>
<input type="submit" id="sendMessage" name="sendMessage" value="Send Email" />
</form>
<?php
// Define some constants
define( "RECIPIENT_NAME", "Denise Rotman" );
define( "RECIPIENT_EMAIL", "hello@deniserotman.com" );
define( "EMAIL_SUBJECT", "deniserotman.com Vistor" );
// Read the form values
$success = false;
$senderName = isset( $_POST['senderName'] ) ? preg_replace( "/[^\.\-\' a-zA-Z0-9]/", "", $_POST['senderName'] ) : "";
$senderEmail = isset( $_POST['senderEmail'] ) ? preg_replace( "/[^\.\-\_\@a-zA-Z0-9]/", "", $_POST['senderEmail'] ) : "";
$message = isset( $_POST['message'] ) ? preg_replace( "/(From:|To:|BCC:|CC:|Subject:|Content-Type:)/", "", $_POST['message'] ) : "";
// If all values exist, send the email
if ( $senderName && $senderEmail && $message ) {
$recipient = RECIPIENT_NAME . " <" . RECIPIENT_EMAIL . ">";
$headers = "From: " . $senderName . " <" . $senderEmail . ">";
$success = mail( $recipient, EMAIL_SUBJECT, $message, $headers );
}
// Return an appropriate response to the browser
if ( isset($_GET["ajax"]) ) {
echo $success ? "success" : "error";
} else {
?>
<html>
<head>
<title>Thanks!</title>
</head>
<body>
<?php if ( $success ) echo "<p>Thanks for sending your message! We'll get back to you shortly.</p>" ?>
<?php if ( !$success ) echo "<p>There was a problem sending your message. Please try again.</p>" ?>
<p>Click your browser's Back button to return to the page.</p>
</body>
</html>
<?php
}
?>
var messageDelay = 2000; // How long to display status messages (in milliseconds)
// Init the form once the document is ready
$( init );
// Initialize the form
function init() {
// Hide the form initially.
// Make submitForm() the form's submit handler.
// Position the form so it sits in the centre of the browser window.
$('#contactForm').show().submit( submitForm );
// When the "Send us an email" link is clicked:
// 1. Fade the content out
// 2. Display the form
// 3. Move focus to the first field
// 4. Prevent the link being followed
$('a[href="#contactForm"]').click( function() {
$('#content').fadeTo( 'slow', .2 );
$('#contactForm').fadeIn( 'slow', function() {
$('#senderName').focus();
} )
return false;
} );
// When the "Cancel" button is clicked, close the form
/* $('#cancel').click( function() {
$('#contactForm').fadeOut();
$('#content').fadeTo( 'slow', 1 );
} );
// When the "Escape" key is pressed, close the form
$('#contactForm').keydown( function( event ) {
if ( event.which == 27 ) {
$('#contactForm').fadeOut();
$('#content').fadeTo( 'slow', 1 );
}
} ); */
}
// Submit the form via Ajax
function submitForm() {
var contactForm = $(this);
// Are all the fields filled in?
if ( !$('#senderName').val() || !$('#senderEmail').val() || !$('#message').val() ) {
// No; display a warning message and return to the form
$('#incompleteMessage').fadeIn().delay(messageDelay).fadeOut();
contactForm.fadeOut().delay(messageDelay).fadeIn();
} else {
// Yes; submit the form to the PHP script via Ajax
$('#sendingMessage').fadeIn();
contactForm.fadeOut();
$.ajax( {
url: contactForm.attr( 'action' ) + "?ajax=true",
type: contactForm.attr( 'method' ),
data: contactForm.serialize(),
success: submitFinished
} );
}
// Prevent the default form submission occurring
return false;
}
// Handle the Ajax response
function submitFinished( response ) {
response = $.trim( response );
$('#sendingMessage').fadeOut();
if ( response == "success" ) {
// Form submitted successfully:
// 1. Display the success message
// 2. Clear the form fields
// 3. Fade the content back in
$('#successMessage').fadeIn().delay(messageDelay).fadeOut();
$('#senderName').val( "" );
$('#senderEmail').val( "" );
$('#message').val( "" );
$('#content').delay(messageDelay+500).fadeTo( 'slow', 1 );
} else {
// Form submission failed: Display the failure message,
// then redisplay the form
$('#failureMessage').fadeIn().delay(messageDelay).fadeOut();
$('#contactForm').delay(messageDelay+500).fadeIn();
}
}

#contactForm { overflow: scroll; }
// If all values exist, send the email
if ( $senderName && $senderEmail && $message ) {
$recipient = RECIPIENT_NAME . " <" . RECIPIENT_EMAIL . ">";
$headers = "From: " . $senderName . " <" . RECIPIENT_EMAIL . ">" . "\r\n" . "Reply-to: " . $senderEmail;
$success = mail( $recipient, EMAIL_SUBJECT, $message, $headers );
}
<script type="text/javascript">
var messageDelay = 500; // How long to display status messages (in milliseconds)
// Init the form once the document is ready
$( init );
// Initialize the form
function init() {
// Hide the form initially.
// Make submitForm() the form's submit handler.
// Position the form so it sits in the centre of the browser window.
$('#contactForm').hide().submit( submitForm ).addClass( 'positioned' );
// When the "Send us an email" link is clicked:
// 1. Fade the content out
// 2. Display the form
// 3. Move focus to the first field
// 4. Prevent the link being followed
$('a[href="#contactForm"]').click( function() {
$('#linkwrapper').fadeTo( 'slow', .2 );
$('#contactForm').fadeIn( 'slow', function() {
$('#senderName').focus();
} )
return false;
} );
// When the "Cancel" button is clicked, close the form
$('#cancel').click( function() {
$('#contactForm').fadeOut();
$('#linkwrapper').fadeTo( 'slow', 1 );
} );
// When the "Escape" key is pressed, close the form
$('#contactForm').keydown( function( event ) {
if ( event.which == 27 ) {
$('#contactForm').fadeOut();
$('#linkwrapper').fadeTo( 'slow', 1 );
}
} );
}
// Submit the form via Ajax
function submitForm() {
var contactForm = $(this);
// Are all the fields filled in?
if ( !$('#senderName').val() || !$('#senderEmail').val() || !$('#message').val() ) {
// No; display a warning message and return to the form
$('#incompleteMessage').fadeIn().delay(messageDelay).fadeOut();
contactForm.fadeOut().delay(messageDelay).fadeIn();
} else {
// Yes; submit the form to the PHP script via Ajax
$('#sendingMessage').fadeIn();
contactForm.fadeOut();
$.ajax( {
url: contactForm.attr( 'action' ) + "?ajax=true",
type: contactForm.attr( 'method' ),
data: contactForm.serialize(),
success: submitFinished
} );
}
// Prevent the default form submission occurring
return false;
}
// Handle the Ajax response
function submitFinished( response ) {
response = $.trim( response );
$('#sendingMessage').fadeOut();
if ( response == "success" ) {
// Form submitted successfully:
// 1. Display the success message
// 2. Clear the form fields
// 3. Fade the content back in
$('#successMessage').fadeIn().delay(messageDelay).fadeOut();
$('#senderName').val( "" );
$('#senderEmail').val( "" );
$('#message').val( "" );
$('#linkwrapper').delay(messageDelay+500).fadeTo( 'slow', 1 );
} else {
// Form submission failed: Display the failure message,
// then redisplay the form
$('#failureMessage').fadeIn().delay(messageDelay).fadeOut();
$('#contactForm').delay(messageDelay+500).fadeIn();
}
}
</script>
<?php
// Define some constants
define( "RECIPIENT_NAME", "Eric Lyons" );
define( "RECIPIENT_EMAIL", "mail@ericmlyons.com" );
// Read the form values
$success = false;
$senderName = isset( $_POST['senderName'] ) ? preg_replace( "/[^\.\-\' a-zA-Z0-9]/", "", $_POST['senderName'] ) : "";
$senderEmail = isset( $_POST['senderEmail'] ) ? preg_replace( "/[^\.\-\_\@a-zA-Z0-9]/", "", $_POST['senderEmail'] ) : "";
$senderSubject = isset( $_POST['senderSubject'] ) ? preg_replace( "/[^\.\-\_\@a-zA-Z0-9]/", "", $_POST['senderSubject'] ) : "";
$message = isset( $_POST['message'] ) ? preg_replace( "/(From:|To:|BCC:|CC:|Subject:|Content-Type:)/", "", $_POST['message'] ) : "";
// If all values exist, send the email
if ( $senderName && $senderEmail && $senderSubject && $message ) {
$recipient = RECIPIENT_NAME . " <" . RECIPIENT_EMAIL . ">";
$headers = "From: " . $senderName . " <" . $senderEmail . ">";
$success = mail( $recipient, $senderSubject, $message, $headers );
}
// Return an appropriate response to the browser
if ( isset($_GET["ajax"]) ) {
echo $success ? "success" : "error";
} else {
?>
<html>
<head>
<title>Thanks!</title>
</head>
<body>
<?php if ( $success ) echo "<p>Thanks for sending your message! We'll get back to you shortly.</p>" ?>
<?php if ( !$success ) echo "<p>There was a problem sending your message. Please try again.</p>" ?>
<p>Click your browser's Back button to return to the page.</p>
</body>
</html>
<?php
}
?>
<?php
// Define some constants
define( "RECIPIENT_NAME", "Action Graphics Sales" );
define( "RECIPIENT_EMAIL", "10000nails@gmail.com" );
define( "EMAIL_SUBJECT", "Quote Request" );
// Read the form values
$success = false;
$senderName = isset( $_POST['senderName'] ) ? preg_replace( "/[^\.\-\' a-zA-Z0-9]/", "", $_POST['senderName'] ) : "";
$senderEmail = isset( $_POST['senderEmail'] ) ? preg_replace( "/[^\.\-\_\@a-zA-Z0-9]/", "", $_POST['senderEmail'] ) : "";
$senderPhone = isset( $_POST['senderPhone'] ) ? preg_replace( "/[^\.\' a-zA-Z0-9]/", "", $_POST['senderName'] ) : "";
$Product = isset( $_POST['cf_drop_down'] );
$message = isset( $_POST['message'] ) ? preg_replace( "/(From:|To:|BCC:|CC:|Subject:|Content-Type:)/", "", $_POST['message'] ) : "";
// If all values exist, send the email
if ( $senderName && $senderEmail && $senderPhone && $Product && $message) {
$recipient = RECIPIENT_NAME . " <" . RECIPIENT_EMAIL . ">";
$headers = "From: " . $senderName . " <" . $senderEmail . ">";
$success = mail( EMAIL_SUBJECT, $recipient, $senderPhone, $Product, $message, $headers );
}
// Return an appropriate response to the browser
if ( isset($_GET["ajax"]) ) {
echo $success ? "success" : "error";
} else {
?>
<html>
<head>
<title>Thanks!</title>
</head>
<body>
<?php if ( $success ) echo "<p>Thanks for sending your message! We'll get back to you shortly.</p>" ?>
<?php if ( !$success ) echo "<p>There was a problem sending your message. Please try again.</p>" ?>
<p>Click your browser's Back button to return to the page.</p>
</body>
</html>
<?php
}
?>

$headers = "From: " . $senderName . " <" . $senderEmail . ">\r\n";
$headers .= "CC: " . $ccName . " <" . $ccEmail . ">\r\n";
function init() {
// Hide the form initially.
// Make submitForm() the form's submit handler.
// Position the form so it sits in the centre of the browser window.
$('#contactForm').hide().submit( submitForm ).addClass( 'positioned' );
// When the "Send us an email" link is clicked:
// 1. Fade the content out
// 2. Display the form
// 3. Move focus to the first field
// 4. Prevent the link being followed
$('a[href="#contactForm"]').click( function() {
$('#[b]linkwrapper[/b]').fadeTo( 'slow', .2 );
$('#contactForm').fadeIn( 'slow', function() {
$('#senderName').focus();
} )


<?php
// Define some constants
define( "RECIPIENT_NAME", "Axiom Build + Print" );
define( "RECIPIENT_EMAIL", "info@theaxnyc.com" );
define( "EMAIL_SUBJECT", "Website email/ quote request" );
define( "SENDER_EMAIL", "info@theaxnyc.com" );
// Read the form values
$success = false;
$senderName = isset( $_POST['senderName'] ) ? preg_replace( "/[^\.\-\' a-zA-Z0-9]/", "", $_POST['senderName'] ) : "";
$replyEmail = isset( $_POST['replyEmail'] ) ? preg_replace( "/[^\.\-\_\@a-zA-Z0-9]/", "", $_POST['replyEmail'] ) : "";
$message = isset( $_POST['message'] ) ? preg_replace( "/(From:|To:|BCC:|CC:|Subject:|Content-Type:)/", "", $_POST['message'] ) : "";
// If all values exist, send the email
if ( $senderName && $replyEmail && $message ) {
$recipient = RECIPIENT_NAME . " <" . RECIPIENT_EMAIL . ">";
$senderEmail = " <" . SENDER_EMAIL . ">";
$headers = "From: " . $senderEmail . "\r\n";
$headers .= "Return-Path: " . $senderName ." <" . $replyEmail . ">\r\n";
$headers .= "Reply-to: " . $senderName . " <" . $replyEmail . ">";
$success = mail( $recipient, EMAIL_SUBJECT, $message, $headers );
}
// Return an appropriate response to the browser
if ( isset($_GET["ajax"]) ) {
echo $success ? "success" : "error";
} else {
?>
<html>
<head>
<title>Thanks!</title>
</head>
<body>
<?php if ( $success ) echo "<p>Thanks for sending your message! We'll get back to you shortly.</p>" ?>
<?php if ( !$success ) echo "<p>There was a problem sending your message. Please try again.</p>" ?>
<p>Click your browser's Back button to return to the page.</p>
</body>
</html>
<?php
}
?>
<?php
// Define some constants
define( "RECIPIENT_NAME", "david" );
define( "RECIPIENT_EMAIL", "....@msn.com" );
define( "EMAIL_SUBJECT", "coment" );
// Read the form values
$success = false;
$senderName = isset( $_POST['senderName'] ) ? preg_replace( "/[^\.\-\' a-zA-Z0-9]/", "", $_POST['senderName'] ) : "";
$senderEmail = isset( $_POST['senderEmail'] ) ? preg_replace( "/[^\.\-\_\@a-zA-Z0-9]/", "", $_POST['senderEmail'] ) : "";
$message = isset( $_POST['message'] ) ? preg_replace( "/(From:|To:|BCC:|CC:|Subject:|Content-Type:)/", "", $_POST['message'] ) : "";
// If all values exist, send the email
if ( $senderName && $senderEmail && $message ) {
$recipient = RECIPIENT_NAME . " <" . RECIPIENT_EMAIL . ">";
$headers = "From: " . $senderName . " <" . $senderEmail . ">";
$success = mail( $recipient, EMAIL_SUBJECT, $message, $headers );
}
// Return an appropriate response to the browser
if ( isset($_GET["ajax"]) ) {
echo $success ? "success" : "error";
} else {
?>
<!DOCTYPE HTML>
<html lang="pt">
<head>
<title>Obrigado</title>
<meta charset="utf-8">
</head>
<body>
<?php if ( $success ) echo "<p>Obrigado pelo seu comentário</p>" ?>
<?php if ( !$success ) echo "<p>Houve um problema no envio do email. Tente novament.</p>" ?>
<p>Click your browser's Back button to return to the page.</p>
</body>
</html>
<?php
}
?>
$('#contactForm').hide().submit( submitForm ).addClass( 'positioned' );
$('#contactForm').fadeOut();
$('#content').fadeTo( 'slow', 1 );
<!doctype html>

<li>
<label>San Francisco</label><input type="checkbox" name="league" id="league" value="SF">
</li>
input[type="checkbox"] {
float: left;
margin: .6em 0;
}



val( "" ) doesn't delay anything.

$senderEmail = isset( $_POST['senderMobile'] ) ? preg_replace( "/[^\.\-\_\a-zA-Z0-9]/", "", $_POST['senderMobile'] ) : "";
$senderMobile = isset( $_POST['senderMobile'] ) ? preg_replace( "/[^\.\-\_\a-zA-Z0-9]/", "", $_POST['senderMobile'] ) : "";
<input type="submit" id="sendMessage" name="sendMessage" value="Send Email" />
<input type="submit" id="sendMessage" name="sendMessage" value="Skicka" />
<input type="submit" id="sendMessage" name="sendMessage" value="Send Email" />
<!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" />
<!-- TemplateBeginEditable name="doctitle" -->
<title>Welcome to 25 Bits!</title>
<!-- TemplateEndEditable -->
<!-- TemplateBeginEditable name="head" -->
<!-- TemplateEndEditable -->
<link href="_css/main_25bits.css" rel="stylesheet" type="text/css" /><!--[if lte IE 7]>
<style>
.content { margin-right: -1px; } /* this 1px negative margin can be placed on any of the columns in this layout with the same corrective effect. */
ul.nav a { zoom: 1; } /* the zoom property gives IE the hasLayout trigger it needs to correct extra whiltespace between the links */
</style>
<![endif]-->
<script src="Scripts/swfobject_modified.js" type="text/javascript"></script>
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
<script src="http://code.vostrel.cz/jquery.reel-bundle.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js" type="text/javascript"></script>
<!--Begins Mail Form Script -->
<script type="text/javascript" src="jquery-1.7.1.min.js"></script>
<script type="text/javascript">
var messageDelay = 2000; // How long to display status messages (in milliseconds)
// Init the form once the document is ready
$( init );
// Initialize the form
function init() {
// Hide the form initially.
// Make submitForm() the form's submit handler.
// Position the form so it sits in the centre of the browser window.
$('#contactForm').hide().submit( submitForm ).addClass( 'positioned' );
// When the "Send us an email" link is clicked:
// 1. Fade the content out
// 2. Display the form
// 3. Move focus to the first field
// 4. Prevent the link being followed
$('a[href="#contactForm"]').click( function() {
$('#content').fadeTo( 'slow', .2 );
$('#contactForm').fadeIn( 'slow', function() {
$('#senderName').focus();
} )
return false;
} );
// When the "Cancel" button is clicked, close the form
$('#cancel').click( function() {
$('#contactForm').fadeOut();
$('#content').fadeTo( 'slow', 1 );
} );
// When the "Escape" key is pressed, close the form
$('#contactForm').keydown( function( event ) {
if ( event.which == 27 ) {
$('#contactForm').fadeOut();
$('#content').fadeTo( 'slow', 1 );
}
} );
}
// Submit the form via Ajax
function submitForm() {
var contactForm = $(this);
// Are all the fields filled in?
if ( !$('#senderName').val() || !$('#senderEmail').val() || !$('#message').val() ) {
// No; display a warning message and return to the form
$('#incompleteMessage').fadeIn().delay(messageDelay).fadeOut();
contactForm.fadeOut().delay(messageDelay).fadeIn();
} else {
// Yes; submit the form to the PHP script via Ajax
$('#sendingMessage').fadeIn();
contactForm.fadeOut();
$.ajax( {
url: contactForm.attr( 'action' ) + "?ajax=true",
type: contactForm.attr( 'method' ),
data: contactForm.serialize(),
success: submitFinished
} );
}
// Prevent the default form submission occurring
return false;
}
// Handle the Ajax response
function submitFinished( response ) {
response = $.trim( response );
$('#sendingMessage').fadeOut();
if ( response == "success" ) {
// Form submitted successfully:
// 1. Display the success message
// 2. Clear the form fields
// 3. Fade the content back in
$('#successMessage').fadeIn().delay(messageDelay).fadeOut();
$('#senderName').val( "" );
$('#senderEmail').val( "" );
$('#message').val( "" );
$('#content').delay(messageDelay+500).fadeTo( 'slow', 1 );
} else {
// Form submission failed: Display the failure message,
// then redisplay the form
$('#failureMessage').fadeIn().delay(messageDelay).fadeOut();
$('#contactForm').delay(messageDelay+500).fadeIn();
}
}
</script>
<!--Ends Mail Form Script -->
<style type="text/css">
body {
background-repeat: repeat;
}
</style>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" />
<!--Google Analitics -->
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-27390220-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<!--End Google Analytics -->
<link href="_css/Styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="container">
<div class="header">
<object id="FlashID" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="20%" height="90">
<param name="movie" value="Logo_25bits_3.swf" />
<param name="quality" value="high" />
<param name="wmode" value="opaque" />
<param name="swfversion" value="6.0.65.0" />
<!-- This param tag prompts users with Flash Player 6.0 r65 and higher to download the latest version of Flash Player. Delete it if you don’t want users to see the prompt. -->
<param name="expressinstall" value="Scripts/expressInstall.swf" />
<param name="SCALE" value="exactfit" />
<!-- Next object tag is for non-IE browsers. So hide it from IE using IECC. -->
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="Logo_25bits_3.swf" width="20%" height="90">
<!--<![endif]-->
<param name="quality" value="high" />
<param name="wmode" value="opaque" />
<param name="swfversion" value="6.0.65.0" />
<param name="expressinstall" value="Scripts/expressInstall.swf" />
<param name="SCALE" value="exactfit" />
<!-- The browser displays the following alternative content for users with Flash Player 6.0 and older. -->
<div>
<h4>Content on this page requires a newer version of Adobe Flash Player.</h4>
<p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" width="112" height="33" /></a></p>
</div>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
</a>
<!-- end .header --></div>
<div class="sidebar1">
<ul class="nav">
<li><a href="equipment.html">Equipment for Rent</a></li>
<li><a href="#">Productions</a></li>
<li><a href="#">Photo Gallery</a></li>
<li><a href="#">Casting</a><!-- end .sidebar1 --></li>
</ul>
</div>
<div class="content">
<h1>While this site is still under construction, "Equipment for Rent" section is ready.</h1>
<p>Call us at 253-217-2377 with all your rental needs or <a href="#contactForm">contact us</a> via E-mail.</p>
<div><form id="contactForm" action="processForm.php" method="post">
<p>Send Us an E-mail...</p>
<ul>
<li>
<label for="senderName">Name:</label>
<input type="text" name="senderName" id="senderName" placeholder="Please type your name" required="required" maxlength="50" />
</li>
<li>
<label for="senderEmail">E-mail:</label>
<input type="email" name="senderEmail" id="senderEmail" placeholder="Please type your email address" required="required" maxlength="60" />
</li>
<li>
<label for="message" style="padding-top: .5em;">Message:</label>
<textarea name="message" id="message" placeholder="Please type your message" required="required" cols="80" rows="10" maxlength="10000"></textarea>
</li>
</ul>
<p>
<input type="submit" id="sendMessage" name="sendMessage" value="Send" />
<input type="button" id="cancel" name="cancel" value="Cancel" />
</p>
<p> </p>
</form>
</div>
<div id="sendingMessage" class="statusMessage"><p>Sending your message. Please wait...</p></div>
<div id="successMessage" class="statusMessage"><p>Thanks for sending your message! We'll get back to you shortly.</p></div>
<div id="failureMessage" class="statusMessage"><p>There was a problem sending your message. Please try again.</p></div>
<div id="incompleteMessage" class="statusMessage"><p>Please complete all the fields in the form before sending.</p></div>
</div>
<div class="footer">
<p class="footer"><a href="terms.html">Terms of Use</a> Privacy Notice Legal</p>
<!-- end .footer --></div>
<!-- end .container --></div>
<script type="text/javascript">
swfobject.registerObject("FlashID");
</script>
</body>
</html>
<?php
// Define some constants
define("RECIPIENT_NAME","Steven Mahoney");
define("RECIPIENT_EMAIL","steven@25bits.com");
define("EMAIL_SUBJECT","Visitor Message");
// Read the form values
$success = false;
$senderName = isset( $_POST['senderName'] ) ? preg_replace( "/[^\.\-\' a-zA-Z0-9]/", "", $_POST['senderName'] ) : "";
$senderEmail = isset( $_POST['senderEmail'] ) ? preg_replace( "/[^\.\-\_\@a-zA-Z0-9]/", "", $_POST['senderEmail'] ) : "";
$message = isset( $_POST['message'] ) ? preg_replace( "/(From:|To:|BCC:|CC:|Subject:|Content-Type:)/", "", $_POST['message'] ) : "";
// If all values exist, send the email
if ( $senderName && $senderEmail && $message ) {
$recipient = RECIPIENT_NAME . " <" . RECIPIENT_EMAIL . ">";
/* $headers = "From: " . $senderName . " <" . $senderEmail . ">"; */
$headers = "From: " . $senderName . " <" . RECIPIENT_EMAIL . ">" . "\r\n" . "Reply-to: " . $senderEmail;
$success = mail( $recipient, EMAIL_SUBJECT, $message, $headers );
}
// Return an appropriate response to the browser
if (isset($_GET["ajax"])) {
echo $success ? "success" : "error";
} else {
?>
<html>
<head>
<title>Thanks!</title>
</head>
<body>
<?php if ( $success ) echo "<p>Thanks for sending your message! We'll get back to you shortly.</p>" ?>
<?php if ( !$success ) echo "<p>There was a problem sending your message. Please try again.</p>" ?>
<p>Click your browser's Back button to return to the page.</p>
</body>
</html>
<?php
}
?>
$phone = isset( $_POST['phone = preg_replace("/[^0-9]/", "", $phone);
if(strlen($phone) == 7)
return preg_replace("/([0-9]{3})([0-9]{4})/", "$1-$2", $phone);
elseif(strlen($phone) == 10)
return preg_replace("/([0-9]{3})([0-9]{3})([0-9]{4})/", "($1)$2-$3", $phone);
else
return $phone;
<select name="mySelect"> ... </select>
$mySelect = isset( $_POST['mySelect'] ) ? preg_replace( "/(From:|To:|BCC:|CC:|Subject:|Content-Type:)/", "", $_POST['mySelect'] ) : "";

/* $headers = "From: " . $senderName . " <" . $senderEmail . ">"; */
$headers = "From: " . $senderName . " <" . RECIPIENT_EMAIL . ">" . "\r\n" . "Reply-to: " . $senderEmail;
// anti-spam time delay check
if((strlen($time_delay[$config]) > 0 && strlen($_POST["time"]) > 0) || (strlen($time_delay[$config]) > 0 && (strlen($_POST["time"]) == 0 || !$_POST["time"])))
{
if((time() - $_POST["time"]) < $time_delay[$config])
$time_message = "<li>This has been stopped by the timer, and is likely spam.</li>\n";
}
/////////2nd method
// anti-spam max URL check
if(strlen($max_url_fields[$config]) > 0)
{
$max_url_message="";
$field_check=preg_split('/,/',$max_url_fields[$config]);
$field_run=sizeof($field_check);
for($i=0;$i<$field_run;$i++)
{
$cur_field_name=$field_check[$i];
$cur_field=$_POST[$cur_field_name];
preg_match_all("/http:/", $cur_field, $matches);
if(count($matches[0]) > $max_urls[$config])
$max_url_message.="<li>This message contains too many URL's.</li>\n";
}
}
$senderEmail = isset( $_POST['senderEmail'] ) ? preg_replace( "/[^\.\-\_\@a-zA-Z0-9]/", "", $_POST['senderEmail'] ) : "";
$phone = isset( $_POST['phone = preg_replace("/[^0-9]/", "", $phone);
<li>
<label for="telephone">Votre téléphone </label>
<input type="text" name="telephone" id="telephone" placeholder="tel" required maxlength="14" />
</li>
$telephone = isset( $_POST['telephone'] ) ? preg_replace( "/[^\ \-0-9]/", "", $_POST['telephone'] ) : "";
...
$message = isset( $_POST['message'] ) ? preg_replace( "/(From:|To:|BCC:|CC:|Subject:|Content-Type:)/", "", $_POST['message'] ) : "";
$message .= "\n\nTelephone: $telephone\n\n";
$('a[href="#contactForm"]').click( function() {
$('#centre').fadeTo( 'slow', .2 );
$('#contactForm').fadeIn( 'slow', function() {
$('#senderName').focus();
} )

). I cannot get this working even if I just download the code and modify the PHP file so that it has my email it does not work. So help? I have a gmail email address.
CreatePage(GetMessage(MSG_THANKS_PAGE),GetMessage(MSG_FORM_OK));
if ($bGotGoodTemplate){
if ( isset($_GET["ajax"]) ) {
$success = 1;
echo $success ? "success" : "error";
} else {
OutputTemplate($SPECIAL_VALUES["good_template"],$aRawDataValues);
}
}
else {
if ( isset($_GET["ajax"]) ) {
$success = 1;
echo $success ? "success" : "error";
} else {
CreatePage(GetMessage(MSG_THANKS_PAGE),GetMessage(MSG_FORM_OK));
}
}


<meta charset="utf-8">
if ( $('#callback').attr('checked') && !$('#telephone').val() ) {
// Display alert
}
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script type="text/javascript">
var messageDelay = 2000; // How long to display status messages (in milliseconds)
// Init the form once the document is ready
$( init );
// Initialize the form
function init() {
// Hide the form initially.
// Make submitForm() the form's submit handler.
// Position the form so it sits in the centre of the browser window.
$('#contactForm').hide().submit( submitForm ).addClass( 'positioned' );
// When the "Send us an email" link is clicked:
// 1. Fade the content out
// 2. Display the form
// 3. Move focus to the first field
// 4. Prevent the link being followed
$('a[href="#contactForm"]').click( function() {
$('#content').fadeTo( 'slow', .2 );
$('#contactForm').fadeIn( 'slow', function() {
$('#senderName').focus();
} )
return false;
} );
// When the "Cancel" button is clicked, close the form
$('#cancel').click( function() {
$('#contactForm').fadeOut();
$('#content').fadeTo( 'slow', 1 );
} );
// When the "Escape" key is pressed, close the form
$('#contactForm').keydown( function( event ) {
if ( event.which == 27 ) {
$('#contactForm').fadeOut();
$('#content').fadeTo( 'slow', 1 );
}
} );
}
// Submit the form via Ajax
function submitForm() {
var contactForm = $(this);
// Are all the fields filled in?
if ( !$('#senderName').val() || !$('#senderEmail').val() || !$('#message').val() ) {
// No; display a warning message and return to the form
$('#incompleteMessage').fadeIn().delay(messageDelay).fadeOut();
contactForm.fadeOut().delay(messageDelay).fadeIn();
} else {
// Yes; submit the form to the PHP script via Ajax
$('#sendingMessage').fadeIn();
contactForm.fadeOut();
$.ajax( {
url: contactForm.attr( 'action' ) + "?ajax=true",
type: contactForm.attr( 'method' ),
data: contactForm.serialize(),
success: submitFinished
} );
}
// Prevent the default form submission occurring
return false;
}
// Handle the Ajax response
function submitFinished( response ) {
response = $.trim( response );
$('#sendingMessage').fadeOut();
if ( response == "success" ) {
// Form submitted successfully:
// 1. Display the success message
// 2. Clear the form fields
// 3. Fade the content back in
$('#successMessage').fadeIn().delay(messageDelay).fadeOut();
$('#senderName').val( "" );
$('#senderEmail').val( "" );
$('#senderPhone').val( "" );
$('#message').val( "" );
$('#senderResume').val( "" );
$('#content').delay(messageDelay+500).fadeTo( 'slow', 1 );
} else {
// Form submission failed: Display the failure message,
// then redisplay the form
$('#failureMessage').fadeIn().delay(messageDelay).fadeOut();
$('#contactForm').delay(messageDelay+500).fadeIn();
}
}
</script>
</head>
<body>
<div class="wideBox">
<h2>Marksmen Vegetation Employment Opportunities</h2>
</div>
<div id="content">
<p style="padding-bottom: 50px; font-weight: bold; text-align: center;"><a href="#contactForm">Click Here to Submit a Resume</a></p>
</div>
<form id="contactForm" action="processForm.php" method="post">
<h2>Submit a Resume online</h2>
<p>Please ensure you select the appropriate job opportunity. Only those selected for an interview will be contacted.</p>
<ul>
<li>
<label for="senderName">Your Name</label>
<input type="text" name="senderName" id="senderName" placeholder="Please type your name" required="required" maxlength="40" />
</li>
<li>
<label for="senderEmail">Your Email Address</label>
<input type="email" name="Email" id="senderEmail" placeholder="Please type your email address" required="required" maxlength="50" />
</li>
<li>
<label for="senderPhone">Your Phone Number</label>
<input type="text" name="Phone" id="senderPhone" placeholder="Please type your phone number" required="required" maxlength="10" />
</li>
<li>
<label for="message" style="padding-top: .5em;">Please paste your cover letter here</label>
<textarea name="textarea" id="message" placeholder="Please type your cover letter" required="required" cols="80" rows="10" maxlength="10000"></textarea>
</li>
<li>
<label for="senderResume">Upload resume in PDF format</label>
<input type="file" name="senderResume" id="senderResume" placeholder="Select a File" required="required" maxlength="50" />
</li>
</ul>
<div id="formButtons">
<input type="submit" id="sendMessage" name="sendMessage" value="Send Resume" />
<input type="button" id="cancel" name="cancel" value="Cancel" />
</div>
</form>
<div id="sendingMessage" class="statusMessage"><p>Sending your message. Please wait...</p></div>
<div id="successMessage" class="statusMessage"><p>Thanks for sending your message! We'll get back to you shortly.</p></div>
<div id="failureMessage" class="statusMessage"><p>There was a problem sending your message. Please try again.</p></div>
<div id="incompleteMessage" class="statusMessage"><p>Please complete all the fields in the form before sending.</p></div>
</body>
</html>
<?php
// Define some constants
define( "RECIPIENT_NAME", "Field Manager" );
define( "RECIPIENT_EMAIL", "daryl@marksmeninc.com" );
define( "EMAIL_SUBJECT", "Website Resume Submission" );
// Read the form values
$success = false;
$senderName = isset( $_POST['senderName'] ) ? preg_replace( "/[^\.\-\' a-zA-Z0-9]/", "", $_POST['senderName'] ) : "";
$senderEmail = isset( $_POST['senderEmail'] ) ? preg_replace( "/[^\.\-\_\@a-zA-Z0-9]/", "", $_POST['senderEmail'] ) : "";
$message = isset( $_POST['message'] ) ? preg_replace( "/(From:|To:|BCC:|CC:|Subject:|Content-Type:)/", "", $_POST['message'] ) : "";
// If all values exist, send the email
if ( $senderName && $senderEmail && $message ) {
$recipient = RECIPIENT_NAME . " <" . RECIPIENT_EMAIL . ">";
$headers = "From: " . $senderName . " <" . $senderEmail . ">";
$success = mail( $recipient, EMAIL_SUBJECT, $message, $headers );
}
// Return an appropriate response to the browser
if ( isset($_GET["ajax"]) ) {
echo $success ? "success" : "error";
} else {
?>
<html>
<head>
<title>Thanks!</title>
</head>
<body>
<?php if ( $success ) echo "<p>Thanks for sending your message! We'll get back to you shortly.</p>" ?>
<?php if ( !$success ) echo "<p>There was a problem sending your message. Please try again.</p>" ?>
<p>Click your browser's Back button to return to the page.</p>
</body>
</html>
<?php
}
?>


<!--[if IE 7]>
<link rel="stylesheet" type="text/css" href="IE7styles.css" />
<![endif]-->

one more thing pdf path is also come from database by the select query on the same page i.e processForm.php i dont required to send any email
<?php
include("config.php");
include("mysql.lib.php");
$success = false;
$senderName = isset( $_POST['senderName'] ) ? preg_replace( "/[^\.\-\' a-zA-Z0-9]/", "", $_POST['senderName'] ) : "";
$senderEmail = isset( $_POST['senderEmail'] ) ? preg_replace( "/[^\.\-\_\@a-zA-Z0-9]/", "", $_POST['senderEmail'] ) : "";
$productid = isset( $_POST['hiddenField'] ) ? preg_replace( "/[^\.\-\_\@a-zA-Z0-9]/", "", $_POST['hiddenField'] ) : "";
/*$currenturl = $_POST['url'];*/
$query = "SELECT pdf FROM products where id=$productid";
$result = mysql_query($query);
while($row = mysql_fetch_array($result))
{
$pdfpath = $row['pdf'];
}
$date = date('m/d/Y', time());
if ( isset($_GET["ajax"]) ) {
echo $success ? "success" : "error";
}
mysql_query("INSERT INTO download (name,email,pdf,productid,downloaddate)
VALUES ('$senderName','$senderEmail','$pdfpath','$productid','$date')");
// force to download a file
$file = "http://localhost/oria/pdf/".$pdfpath."";
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/force-download");
header( "Content-Disposition: attachment; filename=".basename($file));
header( "Content-Description: File Transfer");
@readfile($file);
?>
window.location.href="http://pdf-url"
hope u understand that.... 
window.location.href="http://pdf-url"
<?php
include("config.php");
include("mysql.lib.php");
$success = false;
$senderName = isset( $_POST['senderName'] ) ? preg_replace( "/[^\.\-\' a-zA-Z0-9]/", "", $_POST['senderName'] ) : "";
$senderEmail = isset( $_POST['senderEmail'] ) ? preg_replace( "/[^\.\-\_\@a-zA-Z0-9]/", "", $_POST['senderEmail'] ) : "";
$productid = isset( $_POST['hiddenField'] ) ? preg_replace( "/[^\.\-\_\@a-zA-Z0-9]/", "", $_POST['hiddenField'] ) : "";
$query = "SELECT pdf FROM products where id=$productid";
$result = mysql_query($query);
while($row = mysql_fetch_array($result))
{
$pdfpath = $row['pdf'];
}
$date = date('m/d/Y', time());
mysql_query("INSERT INTO download (name,email,pdf,productid,downloaddate)
VALUES ('$senderName','$senderEmail','$pdfpath','$productid','$date')");
if ( isset($_GET["ajax"]))
{
echo $success ? "success" : "error";
}
else
{
?>
<script language="javascript">
window.location.href="http://elevatormachine.in/pdf/<?php echo $pdfpath; ?>";
</script>
<?php
}
?>
window.location.href="http://elevatormachine.in/pdf/<?php pdfpath ?>"

$senderEmail = isset( $_POST['senderEmail'] ) ? preg_replace( "/[^\.\-\_\@a-zA-Z0-9]/", "", $_POST['senderEmail'] ) : "";
$senderEmail = isset( $_POST['senderEmail'] ) ? preg_replace( "/[^\.\-\_\@a-zA-Z0-9.a-z{2,3}]/", "", $_POST['senderEmail'] ) : "";
// Are all the fields filled in?
if ( !$('#senderName').val() || !$('#senderEmail').val() || !$('#message').val() || ( $('#senderEmail').val().match( /(\.[a-z]{2,4}$)/ ) ) ) {
...
<!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>Kromweb</title>
<link rel="stylesheet" type="text/css" href="estilos/estilos.css"/>
<link href="img/favicon_kromweb.png" rel="shortcut icon"/>
<!--[if IE]>
<link rel="stylesheet" type="text/css" href="estilos_IE.css" />
<![endif]-->
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script type="text/javascript">
var messageDelay = 2000; // How long to display status messages (in milliseconds)
// Init the form once the document is ready
$( init );
// Initialize the form
function init() {
// Hide the form initially.
// Make submitForm() the form's submit handler.
// Position the form so it sits in the centre of the browser window.
$('#contactForm').hide().submit( submitForm ).addClass( 'positioned' );
// When the "Send us an email" link is clicked:
// 1. Fade the content out
// 2. Display the form
// 3. Move focus to the first field
// 4. Prevent the link being followed
$('a[href="#contactForm"]').click( function() {
$('#lista').fadeTo( 'slow', .2 );
$('#contactForm').fadeIn( 'slow', function() {
$('#senderName').focus();
} )
return false;
} );
// When the "Cancel" button is clicked, close the form
$('#cancel').click( function() {
$('#contactForm').fadeOut();
$('#lista').fadeTo( 'slow', 1 );
} );
// When the "Escape" key is pressed, close the form
$('#contactForm').keydown( function( event ) {
if ( event.which == 27 ) {
$('#contactForm').fadeOut();
$('#lista').fadeTo( 'slow', 1 );
}
} );
}
// Submit the form via Ajax
function submitForm() {
var contactForm = $(this);
// Are all the fields filled in?
if ( !$('#senderName').val() || !$('#senderEmail').val() || !$('#message').val() ) {
// No; display a warning message and return to the form
$('#incompleteMessage').fadeIn().delay(messageDelay).fadeOut();
contactForm.fadeOut().delay(messageDelay).fadeIn();
} else {
// Yes; submit the form to the PHP script via Ajax
$('#sendingMessage').fadeIn();
contactForm.fadeOut();
$.ajax( {
url: contactForm.attr( 'action' ) + "?ajax=true",
type: contactForm.attr( 'method' ),
data: contactForm.serialize(),
success: submitFinished
} );
}
// Prevent the default form submission occurring
return false;
}
// Handle the Ajax response
function submitFinished( response ) {
response = $.trim( response );
$('#sendingMessage').fadeOut();
if ( response == "success" ) {
// Form submitted successfully:
// 1. Display the success message
// 2. Clear the form fields
// 3. Fade the content back in
$('#successMessage').fadeIn().delay(messageDelay).fadeOut();
$('#senderName').val( "" );
$('#senderEmail').val( "" );
$('#message').val( "" );
$('#lista').delay(messageDelay+500).fadeTo( 'slow', 1 );
} else {
// Form submission failed: Display the failure message,
// then redisplay the form
$('#failureMessage').fadeIn().delay(messageDelay).fadeOut();
$('#contactForm').delay(messageDelay+500).fadeIn();
}
}
</script>
<!-- Some IE7 hacks and workarounds -->
<!--[if lt IE 8]>
<style>
/* IE7 needs the fields to be floated as well as the labels */
input, textarea {
float: right;
}
#formButtons {
clear: both;
}
/*
IE7 needs an ickier approach to vertical/horizontal centring with fixed positioning.
The negative margins are half the element's width/height.
*/
#contactForm.positioned, .statusMessage {
left: 50%;
top: 50%;
}
#contactForm.positioned {
margin-left: -20em;
margin-top: -16.5em;
}
.statusMessage {
margin-left: -15em;
margin-top: -1em;
}
</style>
<![endif]-->
</head>
<body>
<div id="todo">
<div id="cabecera">
<div id="logo">
<a href="#"><img alt="Kromweb" src="img/logo_kromweb.jpg" title="Kromweb" width="559" height="145" border="0" /></a>
<h1>Titulo</h1>
<h2>Diseño Gráfico | Diseño Web | Publicidad | Merchandising</h2>
</div>
<div id="contacto">
<p ><span>(+34) 655 59 09 80</span></p>
<p> e-mail:<a href="#contactForm"> myname@myweb.com</a></p>
</div>
</div>
<!--LISTA-->
<div id="lista">
<ul class="miniaturas">
<li>
<a href="#">
<img class="min" src="img/chicas/1.jpg" alt="#" border="0"/>
<img class="max" src="img/grandes/1.jpg" alt="#" border="0"/>
</li>
</ul>
</div>
<!--FORMULARIO-->
<form id="contactForm" action="processForm.php" method="post" >
<h2>Mándenos un correo...</h2>
<ul>
<li>
<label for="senderName">Nombre</label>
<input type="text" name="senderName" id="senderName" placeholder="Por favor, escriba su nombre" maxlength="40" required="" />
</li>
<li>
<label for="senderEmail">Correo electrónico</label>
<input type="email" name="senderEmail" id="senderEmail" placeholder="Por favor, escriba su Email" maxlength="50" pattern="^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$" required="" />
</li>
<li>
<label for="message" style="padding-top: .5em;">Mensaje</label>
<textarea name="message" id="message" placeholder="Por favor, escriba su mensaje" cols="80" rows="10" maxlength="10000" required=""></textarea>
</li>
</ul>
<div id="formButtons">
<input type="submit" id="sendMessage" name="sendMessage" value="Enviar Email" />
<input type="button" id="cancel" name="cancel" value="Cancelar" />
</div>
</form>
<div id="sendingMessage" class="statusMessage"><p>Enviando su correo. Por favor, espere...</p></div>
<div id="successMessage" class="statusMessage"><p>¡¡Gracias por enviar su mensaje!!. Le responderemos lo antes posible.</p></div>
<div id="failureMessage" class="statusMessage"><p>Ha habido un problema al enviar su mensaje. Por favor, inténtelo de nuevo.</p></div>
<div id="incompleteMessage" class="statusMessage"><p>Por favor, complete todos los campos del formulario antes de enviarlo.</p></div>
</div>
</body>
</html>