i have bought a template that have built in contact form
problem is that it submits every thing except "company" name
i have spent few hours messing around with it but cant get to work it.
if you can point me to some solution i would be greatful
thanks in advance
this is contact form
<form action="php/contact.php" method="post" id="contactform">
<ol>
<li>
<label for="name">your name <span class="red">*</span></label>
<input id="name" name="name" class="text" />
</li>
<li>
<label for="email">Your email <span class="red">*</span></label>
<input id="email" name="email" class="text" />
</li>
<li>
<label for="company">Company Name</label>
<input id="company" name="company" class="text" />
</li>
<li>
<label for="
subject">Subject</label>
<input id="
subject" name="
subject" class="text" />
</li>
<li>
<label for="message">Message <span class="red">*</span></label>
<textarea id="message" name="message" rows="6" cols="50"></textarea>
</li>
<li class="buttons">
<input type="image" name="imageField" id="imageField" src="images/button.jpg" />
</li>
</ol>
</form>
this is java script
<script type="text/javascript">
// <![CDATA[
jQuery(document).ready(function(){
$('#contactform').submit(function(){
var action = $(this).attr('action');
$.post(action, {
name: $('#name').val(),
email: $('#email').val(),
company: $('#company').val(),
subject: $('#subject').val(),
message: $('#message').val()
},
function(data){
$('#contactform #submit').attr('disabled','');
$('.response').remove();
$('#contactform').before('<p class="response">'+data+'</p>');
$('.response').slideDown();
if(data=='Thanks for your message, will contact you soon.') $('#contactform').slideUp();
}
);
return false;
});
});
// ]]>
</script>
this is php script
if(!$_POST) exit;
$email = $_POST['email'];
//$error[] = preg_match('/\b[A-Z0-9._%-]+@[A-Z0-9.-]+.[A-Z]{2,4}\b/i', $POST['email']) ? '' : 'INVALID EMAIL ADDRESS';
if(!eregi("^[a-z0-9]+([\.-][a-z0-9]+)" ."@"."([a-z0-9]+([.-][a-z0-9]+))+"."\.[a-z]{2,}"."$",$email )){
$error.="Invalid email address entered";
$errors=1;
}
if($errors==1) echo $error;
else{
$values = array ('name','email','message');
$required = array('name','email','message');
$your_email = "
[email protected]";
$email_subject = "New Message: ".$_POST['
subject'];
$email_content = "new message:\n";
foreach($values as $key => $value){
if(in_array($value,$required)){
if ($key != '
subject' && $key != 'company') {
if( empty($_POST[$value]) ) { echo 'Please fill in all required fields, marked with *'; exit; }
}
$email_content .= $value.': '.$_POST[$value]."\n";
}
}
if(@mail($your_email,$email_subject,$email_content)) {
echo 'Thanks for your message, will contact you soon.';
} else {
echo 'ERROR!';
}
}