I created this form a while back and it was working just fine and for some reason it is not working at all now. I have no idea why can someone please shed some light on this for me.
The function of this form was to post info in to two places at the same time. One via the form action & the other via a javascript function.
Here is the form:
<form action="http://oi.vresp.com?fid=0cf1b59e3b" method="POST">
<input type=hidden name="retURL" value="http://www.farms.com/contact-us-thanks">
<div class="row">
<div><label for="first_name">First Name<font color=#bd0000>*</font></label><input class="required" id="first_name" maxlength="40" name="first_name" size="20" type="text" /> </div>
<div><label for="last_name">Last Name<font color=#bd0000>*</font></label><input class="required" id="last_name" maxlength="80" name="last_name" size="20" type="text" /></div>
</div>
<div class="row">
<label for="email">Email<font color=#bd0000>*</font></label><input class="required" id="email" maxlength="80" name="email" size="20" type="text" />
<!--<label for="zip"><strong>Zip</strong></label><input id="zip" maxlength="20" name="zip" size="20" type="text" /> -->
</div>
<div class="row">
<label for="email">Interested in<font color=#bd0000>*</font></label><br />
<label class="cf" style="clear: both;"><input id="00N30000006mral" name="00N30000006mral" type="checkbox" value="1" />Real Estate</label>
<label class="cf"><input id="00N30000006mraq" name="00N30000006mraq" type="checkbox" value="1" /> Membership</label>
<label class="cf"><input id="00N30000006mraq1" name="00N30000006mraq1" type="checkbox" value="1" /> Outings</label>
</div>
<input type="hidden" id="recordType" name="recordType" value="01230000000nCt1">
<div class="row">
How did you hear about us?<br />
<textarea id="00N3000000B6ZCD" name="00N3000000B6ZCD" type="text" wrap="soft"></textarea>
</div>
<div class="row">
<label for="description">Comments/Questions</label><br /><textarea id="description" name="description" type="text" wrap="soft"></textarea>
</div>
<div class="row">
Type in "<strong>Creighton Farms</strong>" (case sensitive)
</div>
<div class="row">
<label id="Security">Security Code<font color=#bd0000>*</font></label><input class="required" id="security_code" maxlength="40" name="security_code" size="10" type="text" />
</div>
<div class="row button-submit"><input type="image" name="submit" id="btnSubmit" name="btnSubmit" src="<?php bloginfo( 'template_url' ); ?>/images/submit-ct.png"></div>
</form>
Here is the Javascript Function
$.ajax({
type: 'POST',
url: '/wp-content/themes/farms/captcha/form.php',
data: { 'first_name': $('#first_name').val(),
'last_name': $('#last_name').val(),
'email': $('#email').val(),
'zip': $('#zip').val(),
'cf_real': $('#00N30000006mral').attr('checked'),
'cf_member': $('#00N30000006mraq').attr('checked'),
'cf_outing': $('#00N30000006mraq1').attr('checked'),
'how_about': $('#00N3000000B6ZCD').val(),
'description': $('#description').val(),
'security_code': $('#security_code').val()
},
async: false,
success: function(data){
ok = false;
if(data=="OK") {
ok_submit = true;
alert('Your form has been successfully sent. Thank you for your staying tuned with us.');
} else {
alert(data);
ok_submit = false;
}
},
error: function(){}
});
}
return ok_submit;
});
Here is the PHP Function:
$message = 'Hi Admin<br /><br />
Below is the message sent from "Contact Us" page in www.creightonfarms.com:<br /><br />
First Name: '.$_POST['first_name'].'<br />
Last Name: '.$_POST['last_name'].'<br />
Email: '.$_POST['email'].'<br />
Interested in: CF - Prospects (Real Estate): '. ($_POST['cf_real']=='checked'?'Yes':'No').
' CF - Membership: '.($_POST['cf_member']=='checked'?'Yes':'No').
' CF - Outings: '.($_POST['cf_outing']=='checked'?'Yes':'No').'<br />
How did you hear about us? <br />- '.$_POST['how_about'].'<br />
Comments/Questions:<br />
- '.$_POST['description'].'<br />
--------------------------------------------------------------------------------------------------------------------<br />
This message is automatically sent from http://www.farms.com';
$to = 'test@test.com';
$subject = 'Farms - Contact Us';
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "
";
$headers .= 'Content-type: text/html; charset=utf-8' . "
";
$headers .= 'From: Farms <info@farms.com>' . "
";
$headers .= 'Cc: more@farms.com'.'
';
$send = mail($to, $subject, $message, $headers);
if($send){
print 'OK';
} else
print 'NO';
} else {
// Insert your code for showing an error message here
echo 'Sorry, you have provided an invalid security code';
}
unset($_SESSION['security_code']);
?>