I'm a novice with php and have been working on a contact form
I am having problems styling the invalid email address entered section. Can anyone point me in the direction of some information that will help me sort this?
Thanks everyone
Code: Select all
<style type="text/css">
.bold {color:#99ca3c;
font-family:"Lucida Sans Unicode", "Lucida Grande", sans-serif;
font-size:12px;}
body {background-color:#000;
background-image:url(../images/bg.png);
background-repeat:no-repeat;}
</style>
<?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','contact','message','company','referer',);
$required = array('name','email','message','referer',);
$your_email = "laura@laura.com";
$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 '<span class="bold">PLEASE FILL IN REQUIRED FIELDS</span>','<br/><br/><a href="http://www.none.co.uk/bonew/contact.html"><span class="bold">Click here to go back</span></a>'; exit; }
}
$email_content .= $value.': '.$_POST[$value]."\n";
}
}
if(@mail($your_email,$email_subject,$email_content)) {
echo '<span class="bold">Message sent!</span>','<br/><br/><a href="http://www.none.co.uk/bonew/contact.html"><span class="bold">Click here to go back to</span></a>';
} else {
echo 'ERROR!';
}
}
?>