Page 1 of 1

Having trouble styling one part of this code

Posted: Wed Aug 11, 2010 5:00 am
by laurajdunn
Hi all,

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!';
	}
}
?>

Re: Having trouble styling one part of this code

Posted: Wed Aug 11, 2010 5:05 am
by requinix
laurajdunn wrote:I am having problems styling the invalid email address entered section.
Incidentally, I'm having problems too: knowing what "having problems" means. What isn't working?

Re: Having trouble styling one part of this code

Posted: Wed Aug 11, 2010 5:07 am
by laurajdunn
haha sorry!!

I'm trying to style the text that reads "invalid email address entered"

I've tried to style it the same way as I have done with the other parts of the code using <span> but it doesn't work.

Re: Having trouble styling one part of this code

Posted: Wed Aug 11, 2010 5:20 am
by laurajdunn

Code: Select all

//$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.="<span class="bold">Invalid email address entered</span>";
	$errors=1;
}
I get this error:

Parse error: syntax error, unexpected T_STRING in /home/oxygengr/public_html/bonew/contact.php on line 22