我一直在本地创建一个演示网站,并且我已经设置了一些完美运行的表单,但是一旦我上传它们,表单就不会提交。但是,它会提交并检查您是否输入了所有正确的信息,但是一旦您将所有内容正确填写完毕,它就会拒绝工作。
不确定是什么问题,因为它在我的机器上完全可以正常工作。
有问题的网站就是这个网站。
表格是:
<div id="ReqInfo">
<form id="frmReqInfo" name="frmReqInfo" method="post" action="includes/_formHandler.php?a=send&src=inforequest">
<fieldset>
<label for="frmNameIR">First Name: <span class="required">*</span></label>
<input type="text" name="frmNameIR" id="frmNameIR" />
<label for="frm2ndNameIR">Surname: <span class="required">*</span></label>
<input type="text" name="frm2ndNameIR" id="frm2ndNameIR" />
<label for="frmAddress1IR">1st Line Address: <span class="required">*</span></label>
<input name="frmAddress1IR" id="frmAddress1IR" type="text" />
<label for="frmAddress2IR">2nd Line Address:</label>
<input name="frmAddress2IR" id="frmAddress2IR" type="text" />
<label for="frmTownIR">City/Town: <span class="required">*</span></label>
<input name="frmTownIR" id="frmTownIR" type="text" />
<label for="frmCountyIR">County: <span class="required">*</span></label>
<input name="frmCountyIR" id="frmCountyIR" type="text" />
<label for="frmPostcodeIR">Postcode: <span class="required">*</span></label>
<input type="text" name="frmPostcodeIR" id="frmPostcodeIR" />
</fieldset>
<fieldset class="fld-second">
<label for="frmTelephoneIR">Telephone: <span class="required">*</span></label>
<input type="text" name="frmTelephoneIR" id="frmTelephoneIR" />
<label for="frmEmailIR">Email: <span class="required">*</span></label>
<input type="text" name="frmEmailIR" id="frmEmailIR" />
<label for="frmCompanyIR">Company:</label>
<input type="text" name="frmCompanyIR" id="frmCompanyIR" />
<label>Information Required: <span class="required">*</span></label>
<select name="frmEnquiryIR">
<option value="Sales call">Recieve a sales call</option>
<option value="Email updates">Recieve email updates</option>
<option value="Brochure in the post">Brochure in the post</option>
<option value="SMS(Text) updates">Recieve updates via Text</option>
</select>
<!--
<label for="frmSalesCallIR">Request a sales call</label>
<input name="frmSalesCallIR" type="checkbox" value="" />
<label for="frmEmailListIR">Sign up for email updates</label>
<input name="frmEmailListIR" type="checkbox" value="" />
<label for="frmBrochureIR">Request a brochure in the post</label>
<input name="frmBrochureIR" type="checkbox" value="" />
<label for="frmTextIR">Sign up for SMS(Text) updates</label>
<input name="frmTextIR" type="checkbox" value="" />
-->
<img src="includes/CaptchaSecurityImages.php?session=inforequest&width=100&height=38&characters=6" alt="captcha" id="frmIRSecImage" height="30" width="100" />
<label for="frmSecurityCode">Security Code: <span class="required">*</span></label>
<input type="text" name="frmSecurityCode" id="frmSecurityCode" maxlength="6" />
<input type="Submit" name="frmSubmitIR" id="frmSubmitIR" value="Submit" />
</fieldset>
</form>
</div>
php验证码是:
<?php
session_start();
/*
* File: CaptchaSecurityImages.php
* Author: Simon Jarvis
* Copyright: 2006 Simon Jarvis
* Date: 03/08/06
* Updated: 07/02/07
* Requirements: PHP 4/5 with GD and FreeType libraries
* Link: http://www.white-hat-web-design.co.uk/articles/php-captcha.php
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details:
* http://www.gnu.org/licenses/gpl.html
*
*/
class CaptchaSecurityImages {
var $font = './monofont.ttf';
function generateCode($characters) {
/* list all possible characters, similar looking characters and vowels have been removed */
$possible = '23456789bcdfghjkmnpqrstvwxyz';
$code = '';
$i = 0;
while ($i < $characters) {
$code .= substr($possible, mt_rand(0, strlen($possible)-1), 1);
$i++;
}
return $code;
}
function CaptchaSecurityImages($sessionName='security_code',$width='120',$height='40',$characters='6') {
$code = $this->generateCode($characters);
/* font size will be 75% of the image height */
$font_size = $height * 0.75;
$image = @imagecreate($width, $height) or die('Cannot initialize new GD image stream');
/* set the colours */
$background_color = imagecolorallocate($image, 255, 255, 255);
//$text_color = imagecolorallocate($image, 20, 40, 100);
$text_color = imagecolorallocate($image, 0, 0, 0);
$noise_color = imagecolorallocate($image, 0, 0, 0);
/* generate random dots in background */
//for( $i=0; $i<($width*$height)/3; $i++ ) {
//imagefilledellipse($image, mt_rand(0,$width), mt_rand(0,$height), 1, 1, $noise_color);
//}
/* generate random lines in background */
for( $i=0; $i<($width*$height)/300; $i++ ) {
imageline($image, mt_rand(0,$width), mt_rand(0,$height), mt_rand(0,$width), mt_rand(0,$height), $noise_color);
}
/* create textbox and add text */
$textbox = imagettfbbox($font_size, 0, $this->font, $code) or die('Error in imagettfbbox function');
$x = ($width - $textbox[4])/2;
$y = ($height - $textbox[5])/2;
imagettftext($image, $font_size, 0, $x, $y, $text_color, $this->font , $code) or die('Error in imagettftext function');
/* output captcha image to browser */
header('Content-Type: image/jpeg');
imagejpeg($image);
imagedestroy($image);
$_SESSION[$sessionName] = $code;
}
}
$sessionName = isset($_GET['session']) ? $_GET['session'] : 'security_code';
$width = isset($_GET['width']) ? $_GET['width'] : '120';
$height = isset($_GET['height']) ? $_GET['height'] : '40';
$characters = isset($_GET['characters']) && $_GET['characters'] > 1 ? $_GET['characters'] : '6';
$captcha = new CaptchaSecurityImages($sessionName,$width,$height,$characters);
?>
处理程序是:
<?php
session_start();
error_reporting(0);
header('Content-type: text/xml');
$subject = '';
function getMailMarkup($strSrc)
{
global $subject;
$strEmail = '<body>';
switch ($strSrc)
{
case 'signup': $subject = " - Download Sign Up";
$strEmail .= 'A new user has signed up for downloads from http://example.com.<br /><br />';
$strEmail .= '<strong>Name:</strong> ' . $_POST['frmNameSU'] . '<br />';
$strEmail .= '<strong>Surame:</strong> ' . $_POST['frm2ndNameSU'] . '<br />';
$strEmail .= '<strong>Email Address:</strong> ' . $_POST['frmEmailSU'] . '<br />';
$strEmail .= '<strong>Company:</strong> ' . $_POST['frmEmailSU'] . '<br />';
break;
case 'pricing': $subject = " - Request for prices";
$strEmail .= 'A new user has signed up to download your price lists http://example.com.<br /><br />';
$strEmail .= '<strong>Name:</strong> ' . $_POST['frmNamePL'] . '<br />';
$strEmail .= '<strong>Surame:</strong> ' . $_POST['frm2ndNamePL'] . '<br />';
$strEmail .= '<strong>Email Address:</strong> ' . $_POST['frmEmailPL'] . '<br />';
$strEmail .= '<strong>Company:</strong> ' . $_POST['frmEmailPL'] . '<br />';
break;
case 'inforequest': $subject = " - Information Request";
$strEmail .= 'You have an information request from http://example.com.<br/><br/><strong>' . $_POST['frmNameIR'] . ' ' . $_POST['frm2ndNameIR'] . '</strong> has requested to recieve <strong>' . $_POST['frmEnquiryIR'] . '</strong> <br /><br />';
$strEmail .= 'Details as follows:<br/>';
$strEmail .= '<strong>Name:</strong> ' . $_POST['frmNameIR'] . '<br />';
$strEmail .= '<strong>Surame:</strong> ' . $_POST['frm2ndNameIR'] . '<br />';
$strEmail .= '<strong>Company:</strong> ' . $_POST['frmCompanyIR'] . '<br />';
$strEmail .= '<strong>Address:</strong> ' . $_POST['frmAddress1IR'] . '<br />';
$strEmail .= '<strong>Address:</strong> ' . $_POST['frmAddress2IR'] . '<br />';
$strEmail .= '<strong>Town:</strong> ' . $_POST['frmTownIR'] . '<br />';
$strEmail .= '<strong>County:</strong> ' . $_POST['frmCountyIR'] . '<br />';
$strEmail .= '<strong>Telephone:</strong> ' . $_POST['frmTelephoneIR'] . '<br />';
$strEmail .= '<strong>Email:</strong> ' . $_POST['frmEmailIR'] . '<br />';
$strEmail .= '<strong>Enquiry:</strong> ' . $_POST['frmEnquiryIR'];
break;
}
$strEmail .= '</body>';
return $strEmail;
}
if($_GET['a'] == 'send') {
if(($_SESSION[$_GET['src']] == $_POST['frmSecurityCode']) && (!empty($_SESSION[$_GET['src']]))) {
$thedate = date('l dS \of F Y h:i:s A');
$email = "myemail@gmail.com";
$to = $email;
$random_hash = md5(date('r', time()));
switch ($_GET['src'])
{
case 'signup': $headers = "From: " . $_POST['frmEmailSU'];
break;
case 'pricing': $headers = "From: " . $_POST['frmEmailPL'];
break;
case 'inforequest': $headers = "From: " . $_POST['frmEmailIR'];
break;
}
$headers .= "\r\nMIME-Version: 1.0\n";
$headers .= "Content-Type: text/html; charset=iso-8859-1";
$message = getMailMarkup($_GET['src']);
$mail_sent = @mail( $to, $subject, $message, $headers );
//$hasSubmitCookie = 'yes';
//$expire = time()+60*60*24*30;
//setcookie('hasSubmit', $hasSubmitCookie, $expire);
$_SESSION["submitted"] = "yes" ;
//unset($_SESSION[$_GET['src']]);
echo '<root><code>0</code><message>Thank you for your request</message></root>';
//echo '<root><code>0</code><message>' . $message . '</message></root>';
}
else {
echo '<root><code>1</code><message>Security Code was not correct, please try again.</message></root>';
}
}
?>
和我的js文件是这样的:
/ *作者:
* /
$(function(){
$('#home-images').cycle({
fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
speed: 2000,
timeout: 3000
});
$('#zen-range').cycle({
fx: 'fade'
});
$('#m-range').cycle({
fx: 'fade'
});
$('#frmSignUp').ajaxForm( { beforeSubmit: validateSignUpForm, success: handleResponse } );
$('#frmReqInfo').ajaxForm( { beforeSubmit: validateReqInfoForm, success: handleResponse } );
$('#frmPriceList').ajaxForm( { beforeSubmit: validatePriceListForm, success: handleResponse });
if ($('div#content').hasClass('products')) {
$('ul#sub-nav').slideToggle(320);
}
});
function validateSignUpForm(formData, jqForm, options) {
var form = jqForm[0];
if (form.frmNameSU.value == '') {
form.frmNameSU.focus();
alert('Please enter your first name');
return false;
}
if (form.frm2ndNameSU.value == '') {
form.frm2ndNameSU.focus();
alert('Please enter your surname');
return false;
}
if (!checkEmail(form.frmEmailSU.value))
{
form.frmEmailSU.focus();
alert('Please enter a valid email address');
return false;
}
if (form.frmSecurityCode.value == '') {
form.frmSecurityCode.focus();
alert('Please enter the security code');
return false;
}
}
function validatePriceListForm(formData, jqForm, options) {
var form = jqForm[0];
if (form.frmNamePL.value == '') {
form.frmNamePL.focus();
alert('Please enter your first name');
return false;
}
if (form.frm2ndNamePL.value == '') {
form.frm2ndNamePL.focus();
alert('Please enter your surname');
return false;
}
if (!checkEmail(form.frmEmailSU.value))
{
form.frmEmailPL.focus();
alert('Please enter a valid email address');
return false;
}
if (form.frmSecurityCode.value == '') {
form.frmSecurityCode.focus();
alert('Please enter the security code');
return false;
}
}
function validateReqInfoForm(formData, jqForm, options) {
var form = jqForm[0];
var regEx = new RegExp("/[0-9]/");
if (form.frmNameIR.value == '') {
form.frmNameIR.focus();
alert('Please enter your first name');
return false;
}
if (form.frm2ndNameIR.value == '') {
form.frm2ndNameIR.focus();
alert('Please enter your surname');
return false;
}
if (form.frmAddress1IR.value == '') {
form.frmAddress1IR.focus();
alert('Please enter the first line of your address');
return false;
}
if (form.frmTownIR.value == '') {
form.frmTownIR.focus();
alert('Please enter the City/Town you live in');
return false;
}
if (form.frmCountyIR.value == '') {
form.frmCountyIR.focus();
alert('Please enter the County you live in');
return false;
}
if (form.frmPostcodeIR.value == '') {
form.frmPostcodeIR.focus();
alert('Please enter your postcode');
return false;
}
if (form.frmTelephoneIR.value == '') {
form.frmTelephoneIR.focus();
alert('Please enter your telephone number');
return false;
} else if (form.frmTelephoneIR.value.length != 11 || form.frmTelephoneIR.value.match(regEx) ) {
form.frmTelephoneIR.focus();
alert('Please enter a valid phone number');
return false
}
if (!checkEmail(form.frmEmailIR.value))
{
form.frmEmailIR.focus();
alert('Please enter a valid email address');
return false;
}
if (form.frmSecurityCode.value == '') {
form.frmSecurityCode.focus();
alert('Please enter the security code');
return false;
}
}
function handleResponse(responseXML) {
var code = $('code', responseXML).text();
if (code != 0) {
var message = $('message', responseXML).text();
alert(message);
//TODO: reload captcha
}
else
{
var message = $('message', responseXML).text();
alert(message);
$('#ReqInfo').find(':input').each(function() {
if ($(this).val() != 'Submit')
{
$(this).val('');
}
});
//$('#askExpertPop').find(':input').each(function() { $(this).val(''); });
$('#SignUp').find(':input').each(function() { if ($(this).val() != 'Submit')
{
$(this).val('');
}
window.location = 'downloads.php';
});
$('#PriceList').find(':input').each(function() { if ($(this).val() != 'Submit')
{
$(this).val('');
}
window.location = 'downloads.php';
});
}
return false;
}
function checkEmail(strEmail) {
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (!filter.test(strEmail)) {
return false;
}
return true;
}
anyhelp将不胜感激!