Hi Guys,

I'm struggling a little here and I'm looking for some help to some add some sort of versification system to my contact form. A simple versification for some sort of security (anti-spam) would do, as it's better than nothing I guess.

Below is the code from my page and the contactform.php that I'm using, I didn't write the contactform.php file and I'm not very php savvy yet or confident enough editing it.

Do any of you have any resources, where I could add some simple versification to this.

Also, I have added a telephone number label / field into the form, but I'm not quite sure

Thanks.

Code:
<form action="contactform.php" method="post" id="contactform">
<ol>
<li>
                <label for="name">What is your name?<br /></label>
                <input id="name" name="name" class="text" />
</li>
<li>
                <label for="email">Your e-mail<br /></label>
                <input id="email" name="email" class="text" />
</li>
<li>
                <label for="telephone">Tel. Number<br /></label>
                <input id="telephone" name="telephone" class="text" />
</li>
<li>
                <label for="message">Your message<br /></label>
                <textarea id="message" name="message" rows="6" cols="50"></textarea>
</li>
<li class="buttons">
                <input type="submit" value="Submit" id="submit" />
</li>
 </ol>
</form>

PHP 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','telephone');
$required = array('name','email','message');
 
$your_email "blah@blah.com";
$email_subject "New Message";
$email_content "new message:\n";
 
//for( $i = 0 ; $i < count( $values ) ; ++$i ) {
//    for( $c = 0 ; $c < count( $required ) ; ++$c ) {
//        if( $values[$i]==$required[$c] ) {
//            echo $required[$x];
//            if( empty($_POST[$values[$i]]) ) { echo 'PLEASE FILL IN REQUIRED FIELDS'; exit; }
//        }
//    }
//    $email_content .= $values[$i].': '.$_POST[$values[$i]]."\n";
//}

foreach($values as $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!';
}
}
?>