Switch from testing site to live site breaks jQuery slide
Hello,
I recently got my jQuery contact form up and running on my
testing site. The main function of jQuery in this form is to slide in a hidden DIV with customized error reporting or an 'accepted' status when the user submits the form. Satisfied with the result, I decided to switch it over to the live
development site. As you can see, when submitted, the user is redirected to a new page with the errors/acceptance instead of the jQuery slide effect. To the best of my knowledge I have updated all the paths to reflect the new directory structure. Other than that, I don't have a clue what I'm missing. Any help would be greatly appreciated!
If you don't want to wade through the source of the above sites, I have included the main snippets below.
sendmail.php (form action)
-
<?php
// Who you want to recieve the emails from the form.
$sendto = 'nthompson@trainingevolved.com';
// The subject you'll see in your inbox
$subject = 'FireTide Website Enquiry';
// Message for the user when they do not fill in the form correctly.
$errormessage = 'Oops! There seems to have been a problem. May we suggest...';
// Message for the user when he/she fills in the form correctly.
$thanks = "Thanks for the email! We'll get back to you as soon as possible!";
// Message for the bot when it fills in in at all.
$honeypot = "You filled in the honeypot! If you're human, try again!";
// Various messages displayed when the fields are empty.
$emptyfirstname = 'Please enter your first name';
$emptylastname = 'Please enter your last name';
$emptycompany = 'Please enter your company';
$emptyaddress = 'Please enter your address';
$emptycity = 'Please enter your city';
$emptystate = 'Please enter your state';
$emptyzipcode = 'Please enter your zipcode';
$emptyemail = 'Please enter your email';
$emptytele = 'Please enter your phone number';
$emptymessage = 'Please enter a message';
// Various messages displayed when the fields are incorrectly formatted.
$alertname = 'Please enter a REAL name.';
$alertemail = 'Email must be in the form <i>name@example.com</i>';
$alertzipcode = 'Zipcode must contain five numbers, such as <i>12345</i>';
$alerttele = 'Phone must be in the form <i>555-555-5555</i>?';
$alertmessage = 'You cannot use parenthesis or other escaping characters in the message.';
$alertcaptcha = 'You filled out the CAPTCHA incorrectly, please try again.';
//Setting used variables.
$alert = '';
$pass = 0;
// Sanitizing the data, kind of done via error messages first. Twice is better!
function clean_var($variable) {
$variable = strip_tags(stripslashes(trim(rtrim($variable))));
return $variable;
}
//The first if for honeypot.
if ( empty($_REQUEST['last']) ) {
// A bunch of if's for all the fields and the error messages.
if ( empty($_REQUEST['firstname']) ) {
$pass = 1;
$alert .= "<li>" . $emptyfirstname . "</li>";
} elseif ( ereg( "[][{}()*+?.\\^$|]", $_REQUEST['firstname'] ) ) {
$pass = 1;
$alert .= "<li>" . $alertfirstname . "</li>";
}
if ( empty($_REQUEST['lastname']) ) {
$pass = 1;
$alert .= "<li>" . $emptylastname . "</li>";
} elseif ( ereg( "[][{}()*+?.\\^$|]", $_REQUEST['lastname'] ) ) {
$pass = 1;
$alert .= "<li>" . $alertlastname . "</li>";
}
if ( empty($_REQUEST['company']) ) {
$pass = 1;
$alert .= "<li>" . $emptycompany . "</li>";
} elseif ( ereg( "[][{}()*+?.\\^$|]", $_REQUEST['company'] ) ) {
$pass = 1;
$alert .= "<li>" . $alertcompany . "</li>";
}
if ( empty($_REQUEST['address']) ) {
$pass = 1;
$alert .= "<li>" . $emptyaddress . "</li>";
} elseif ( ereg( "[][{}()*+?.\\^$|]", $_REQUEST['address'] ) ) {
$pass = 1;
$alert .= "<li>" . $alertaddress . "</li>";
}
if ( empty($_REQUEST['city']) ) {
$pass = 1;
$alert .= "<li>" . $emptycity . "</li>";
} elseif ( ereg( "[][{}()*+?.\\^$|]", $_REQUEST['city'] ) ) {
$pass = 1;
$alert .= "<li>" . $alertcity . "</li>";
}
if ( $_REQUEST['state'] == '---' ) {
$pass = 1;
$alert .= "<li>" . $emptystate . "</li>";
} elseif ( ereg( "[][{}()*+?.\\^$|]", $_REQUEST['state'] ) ) {
$pass = 1;
$alert .= "<li>" . $alertstate . "</li>";
}
if ( empty($_REQUEST['zipcode']) ) {
$pass = 1;
$alert .= "<li>" . $emptyzipcode . "</li>";
} elseif ( !ereg( "\(?[0-9]{5}\)?", $_REQUEST['zipcode'] ) ) {
$pass = 1;
$alert .= "<li>" . $alertzipcode . "</li>";
}
if ( empty($_REQUEST['email']) ) {
$pass = 1;
$alert .= "<li>" . $emptyemail . "</li>";
} elseif ( !eregi("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$", $_REQUEST['email']) ) {
$pass = 1;
$alert .= "<li>" . $alertemail . "</li>";
}
if ( empty($_REQUEST['tele']) ) {
$pass = 1;
$alert .= "<li>" . $emptytele . "</li>";
} elseif ( !ereg( "\(?[0-9]{3}\)?[-. ]?[0-9]{3}[-. ]?[0-9]{4}", $_REQUEST['tele'] ) ) {
$pass = 1;
$alert .= "<li>" . $alerttele . "</li>";
}
if ( empty($_REQUEST['message']) ) {
$pass = 1;
$alert .= "<li>" . $emptymessage . "</li>";
} elseif ( ereg( "[][{}()*+?\\^$|]", $_REQUEST['message'] ) ) {
$pass = 1;
$alert .= "<li>" . $alertmessage . "</li>";
}
//If the user err'd, print the error messages.
if ( $pass==1 ) {
//This first line is for ajax/javascript.
echo "<script>$(\".message\").hide(\"slow\").show(\"slow\"); </script>";
echo "<img src='http://www.firetidecreative.com/wp-content/themes/firetide/images/error_btn.png' /><b>" . $errormessage . "</b>";
echo "<ul>";
echo $alert;
echo "</ul>";
// If the user didn't err and there is in fact a message, time to email it.
} elseif (isset($_REQUEST['message'])) {
//Construct the message.
$message = "From: " . clean_var($_REQUEST['firstname']) . clean_var($_REQUEST['lastname']) . "\n";
$message .= "Company: " . clean_var($_REQUEST['company']) . "\n";
$message .= "Address: " . clean_var($_REQUEST['address']) . "\n";
$message .= "City: " . clean_var($_REQUEST['city']) . "\n";
$message .= "State: " . clean_var($_REQUEST['state']) . "\n";
$message .= "Zipcode: " . clean_var($_REQUEST['zipcode']) . "\n";
$message .= "Email: " . clean_var($_REQUEST['email']) . "\n";
$message .= "Telephone: " . clean_var($_REQUEST['tele']) . "\n";
$message .= "Fax: " . clean_var($_REQUEST['fax']) . "\n";
$message .= "Interested In: " . clean_var($_REQUEST['checkbox1']) . clean_var($_REQUEST['checkbox2']) . clean_var($_REQUEST['checkbox3']) . "\n";
$message .= "How did you hear about us? " . clean_var($_REQUEST['tracking']) . "\n";
$message .= "Message: \n" . clean_var($_REQUEST['message']);
$header = 'From:'. clean_var($_REQUEST['email']);
//Mail the message - for production
mail($sendto, $subject, $message, $header);
//This is for javascript,
echo "<script>$(\".message\").hide(\"slow\").show(\"slow\").animate({opacity: 1.0}, 4000); $(':input').clearForm() </script>";
echo "<img src='http://www.firetidecreative.com/wp-content/themes/firetide/images/accepted.png' />" . $thanks;
die();
//Echo the email message - for development
//echo "<br/><br/>" . $message;
}
//If honeypot is filled, trigger the message that bot likely won't see.
} else {
echo "<script>$(\".message\").hide(\"slow\").show(\"slow\"); </script>";
echo $honeypot;
}
error_reporting (E_ALL);
?>
javascript calls (in the HEAD of my page)
-
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
// This is more like it!
});
</script>
<script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/js/jquery.form.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var options = {
target: '#alert',
beforeSubmit: showRequest,
success: showResponse
};
$('#contactForm').ajaxForm(options);
});
function showRequest(formData, jqForm, options) {
var queryString = $.param(formData);
return true;
}
function showResponse(responseText, statusText) {
}
$.fn.clearForm = function() {
return this.each(function() {
var type = this.type, tag = this.tagName.toLowerCase();
if (tag == 'form')
return $(':input',this).clearForm();
if (type == 'text' || type == 'password' || tag == 'textarea')
this.value = '';
else if (type == 'checkbox' || type == 'radio')
this.checked = false;
else if (tag == 'select')
this.selectedIndex = -1;
});
};
</script>
It shouldn't make any difference, but I am running the website through WordPress 2.8. If I failed to include any pertinent info, please let me know.
Again, any help would be absolutely incredible! I am stumped.
Thanks,
Nick