[RESOLVED] form not submitting correctly
hey everyone,
i have this captcha form, and everything seems to be working fine, but if i mess up one of the fields or captcha upon submit, it will warn me to fix it, after fixing it it won't submit at all, i just keep getting the incorrect captcha warning. can anybody help me figure out why? any help would be greatly appreciated. below you can find my form code and validation script!
PHP Code:
<?php
$your_email = 'mdesmond@email.com' ;
session_start ();
$errors = '' ;
$facname = '' ;
$facaddress = '' ;
$faccity = '' ;
$facstate = '' ;
$facphone = '' ;
$emailpgatin = '' ;
$ebayid = '' ;
$emailebay = '' ;
$pganame = '' ;
$pgaid = '' ;
if(isset( $_POST [ 'submit' ]))
{
$facname = $_POST [ 'facname' ];
$facaddress = $_POST [ 'facaddress' ];
$faccity = $_POST [ 'faccity' ];
$facstate = $_POST [ 'facstate' ];
$facphone = $_POST [ 'facphone' ];
$emailpgatin = $_POST [ 'emailpgatin' ];
$ebayid = $_POST [ 'ebayid' ];
$emailebay = $_POST [ 'emailebay' ];
$pganame = $_POST [ 'pganame' ];
$pgaid = $_POST [ 'pgaid' ];
///------------Do Validations-------------
if(empty( $_SESSION [ '6_letters_code' ] ) ||
strcasecmp ( $_SESSION [ '6_letters_code' ], $_POST [ '6_letters_code' ]) != 0 )
{
//Note: the captcha code is compared case insensitively.
//if you want case sensitive match, update the check above to
// strcmp()
$errors .= "<p class='captcha-miss' align='center'>The captcha code does not match!</p>" ;
}
if(empty( $errors ))
{
//send the email
$to = $your_email ;
$subject = "FORM SUBMISSION _ PGA TIN _ EBAY" ;
$from = $your_email ;
$ip = isset( $_SERVER [ 'REMOTE_ADDR' ]) ? $_SERVER [ 'REMOTE_ADDR' ] : '' ;
$body = "A user from $facname , submitted the following:\n" .
"Facility Name: $facname \n" .
"Facility Address: $facaddress \n" .
"Facility City: $faccity \n" .
"Facility State: $facstate \n" .
"Telephone: $facphone \n" .
"PGA TIN Email: $emailpgatin \n" .
"eBay ID: $ebayid \n" .
"eBay Email: $emailebay \n" .
"PGA Professional Name: $pganame \n" .
"PGA Member ID: $pgaid \n" .
"IP: $ip \n" ;
$headers = "From: $from \r\n" ;
$headers .= "Reply-To: $emailpgatin \r\n" ;
mail ( $to , $subject , $body , $headers );
$success = '' ;
$success .= "<p class='success' align='center'>Your form has been submitted!</p>" ;
}
}
// Function to validate against any email injection attempts
function IsInjected ( $str )
{
$injections = array( '(\n+)' ,
'(\r+)' ,
'(\t+)' ,
'(%0A+)' ,
'(%0D+)' ,
'(%08+)' ,
'(%09+)'
);
$inject = join ( '|' , $injections );
$inject = "/ $inject /i" ;
if( preg_match ( $inject , $str ))
{
return true ;
}
else
{
return false ;
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Untitled Document</title>
<style>
body{font-size:12px;font-family:Verdana, Geneva, sans-serif;}
#contact-form {font-size:12px;font-family:Verdana, Geneva, sans-serif;position:relative;vertical-align:top;z-index:1;margin:0;}
#contact-form fieldset {border:none;padding:0; width:100%; overflow:hidden;}
#contact-form label {display:block; min-height:20px; position:relative;color:#666;font-weight:bold;}
#contact-form input, #contact-form textarea {padding: 4px 20px 5px;margin:0;font: 12px Arial, Helvetica, sans-serif;color:#000000;background:#fff;outline:none;border:1px solid #d3d3d3;width:182px;box-shadow:none}
#contact-form .area .error {float:none;}
#contact-form textarea {width:422px;height:194px;resize:none;overflow:auto;}
#contact_form_errorloc ul{border:1px solid red;width:500px;font-size:12px;color:red;background-color:#f6e8e8;padding:10px 20px}
.captcha-miss{border:1px solid red;width:550px;;color:red;background-color:#f6e8e8;padding:10px 0}
.success{border:1px solid #04d822;width:550px;color:#029e18;background-color:#d5f9d8;padding:10px 0}
.fail{border:1px solid red;width:550px;color:red;background-color:#f6e8e8;padding:10px 0}
.shadow{-moz-box-shadow:inset 0 0 2px #000000;-webkit-box-shadow:inset 0 0 2px #000000;box-shadow:inset 0 0 2px #000000;}
</style>
<script language="JavaScript" src="scripts/gen_validatorv31.js" type="text/javascript"></script>
<script>
window.onload = function () {
for(var f in document.getElementsByTagName("contact_form"))
f.reset();
}
</script>
</head>
<body>
<?php echo $success ; ?>
<?php
if(!empty( $errors )){
echo "<p class='err'>" . nl2br ( $errors ). "</p>" ;
}
?>
<div id='contact_form_errorloc' class='err'></div>
<form method="POST" name="contact_form" action="<?php echo htmlentities ( $_SERVER [ 'PHP_SELF' ]); ?> " id="contact-form">
<table width="600" border="0" cellspacing="0" cellpadding="6">
<tr>
<td width="294">
<label for='facname'>Facility Name</label>
<input type="text" name="facname" value='<?php echo htmlentities ( $facname ) ?> ' class="shadow">
</td>
<td width="277">
<label for='facaddress'>Facility Address</label>
<input type="text" name="facaddress" value='<?php echo htmlentities ( $facaddress ) ?> '>
</td>
</tr>
<tr>
<td>
<label for='faccity'>Facility City</label>
<input type="text" name="faccity" value='<?php echo htmlentities ( $faccity ) ?> '>
</td>
<td>
<label for='facstate'>Facility State</label>
<input type="text" name="facstate" value='<?php echo htmlentities ( $facstate ) ?> '>
</td>
</tr>
<tr>
<td>
<label for='facphone'>Phone Number</label>
<input type="text" name="facphone" value='<?php echo htmlentities ( $facphone ) ?> '>
</td>
<td> </td>
</tr>
<tr>
<td>
<label for='emailpgatin'>PGA Trade-In Network Email</label>
<input type="text" name="emailpgatin" value='<?php echo htmlentities ( $emailpgatin ) ?> '>
</td>
<td> </td>
</tr>
<tr>
<td>
<label for='emailebay'>eBay Email<br />(should be the same as PGA TIN email)</label>
<input type="text" name="emailebay" value='<?php echo htmlentities ( $emailebay ) ?> '>
</td>
<td>
<label for='ebayid'>eBay User ID</label>
<input type="text" name="ebayid" value='<?php echo htmlentities ( $ebayid ) ?> '>
</td>
</tr>
<tr>
<td>
<label for='pganame'>PGA Professional Name</label>
<input type="text" name="pganame" value='<?php echo htmlentities ( $pganame ) ?> '>
</td>
<td>
<label for='pgaid'>PGA Member ID</label>
<input type="text" name="pgaid" value='<?php echo htmlentities ( $pgaid ) ?> '>
</td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>
<img src="captcha_code_file.php?rand=<?php echo rand (); ?> " id='captchaimg' ><br />
<label for='message'>Enter the code above here :</label>
<input id="6_letters_code" name="6_letters_code" type="text"><br />
<small>Can't read the image? click <a href='javascript : refreshCaptcha();'>here</a> to refresh</small>
</td>
<td> </td>
</tr>
<tr>
<td>
<input type="submit" value="Submit" name='submit'>
</td>
<td> </td>
</tr>
</table>
</form>
<script language="JavaScript">
// Code for validating the form
// Visit http://www.javascript-coder.com/html-form/javascript-form-validation.phtml
// for details
var frmvalidator = new Validator("contact_form");
//remove the following two lines if you like error message box popups
frmvalidator.EnableOnPageErrorDisplaySingleBox();
frmvalidator.EnableMsgsTogether();
frmvalidator.addValidation("facname","req","Please provide your Facility's Name");
frmvalidator.addValidation("facaddress","req","Please provide your Facility's Address");
frmvalidator.addValidation("faccity","req","Please provide your Facility's City");
frmvalidator.addValidation("facstate","req","Please provide your Facility's State");
frmvalidator.addValidation("facphone","req","Please provide your Phone");
frmvalidator.addValidation("emailpgatin","email","Please Check your TIN Email");
frmvalidator.addValidation("emailpgatin","req","Please Check your TIN Email");
frmvalidator.addValidation("ebayid","req","Please provide your name");
frmvalidator.addValidation("emailebay","email","Please Check your eBay Email");
frmvalidator.addValidation("emailebay","req","Please Check your eBay Email");
frmvalidator.addValidation("pganame","req","Please provide your PGA Professional Name");
frmvalidator.addValidation("pgaid","req","Please provide your PGA ID");
</script>
<script language='JavaScript' type='text/javascript'>
function refreshCaptcha()
{
var img = document.images['captchaimg'];
img.src = img.src.substring(0,img.src.lastIndexOf("?"))+"?rand="+Math.random()*1000;
}
</script>
</body>
</html>
"Problems cannot be solved by the same level of thinking that created them.”
"Problems cannot be solved by the same level of thinking that created them.”
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Bookmarks