Contact Form not processing all fields

Good day,

My site www.supernet.co.za/contact.html
The contact form there sends through the name email and message but nothing else. if i add in a field for “number” the form does not process it still asks for required field. I have basic php knowledge could some1 please give me a hand. I would like the form to process name email tel message and company. If i add the desired fields into the php doc it does not process the form at all.

Please see form data and php data below.

Thanks in advance !!

<form action="contact.php" method="post" id="contactform"> <ol> <li> <label for="name">First 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="number">Number</label> <input id="number" name="number" 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/send.gif" /> </li> </ol> </form>

[php]<?php

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’,‘number’);

$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 != 'number') {
	  if( empty($_POST[$value]) ) { echo 'PLEASE FILL IN REQUIRED FIELDS'; exit; }
	}
	$email_content .= $value.': '.$_POST[$value]."\n";
  }
}
 
if(@mail($your_email,$email_subject,$email_content)) {
	echo 'Message sent!'; 
} else {
	echo 'ERROR!';
}

}
?>[/php]

Hi,

Please find code

[php]
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’,‘number’);
$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( empty($_POST[$value]) ) {
echo ‘PLEASE FILL IN REQUIRED FIELDS’; exit;
}
$email_content .= $value.’: '.$_POST[$value].”\n”;
}
}
if(@mail($your_email,$email_subject,$email_content)) {
echo ‘Message sent!’;
} else {
echo ‘ERROR!’;
}
}
[/php]

Thnks for the quick reply,
Changed the php code still only processing through the message,email and name…

Sponsor our Newsletter | Privacy Policy | Terms of Service