Hey, I am new to PHP and I wrote this it supposed to validate the from and add the errors to an array variable (which will be showed on later), I am having problems on line 41, when I run the script it says Parse error: syntax error, unexpected '{' in C:\xampp\htdocs\register.php on line 41 and I am unable to find any parse error.

Here's my code :

<?php
include("header.html");
include("nav.html");
include("sidebars.html");
?>
<html>
<form action="register.php" method="post">
<fieldset>
<legend>Form 1</legend>
First Name : <input type="text" name="fname"><br><br>
Last Name  : <input type="text" name="lname"><br><br>
Email      : <input type="text" name="email"><br><br>
Password   : <input type="password" name="pass1"><br><br>
Re-enter pass : <input type="password" name="pass2"><br><br>
<input type="submit" name="submit" value="Register Now">
<input type="hidden" name="submitted" value="TRUE">
</fieldset>
</form>
</html>
<?php
$errors=array();
if(isset($_POST['submitted'])){
	if(empty($_POST['fname'])){
		$errors[]="You forgot to enter first name";
	}
	   else{
		   $fn=$_POST['fname'];
	   }
	if(empty($_POST['lname'])){
		$errors[]="You forgot to enter last name";
	}
	   else{
		   $ln=$_POST['lname'];
	   }
	if(empty($_POST['email'])){
		$errors[]="You forgot to enter email";
	}
	  else{
		  $email=$_POST['email'];
	  }
	if(!empty($_POST['pass1']){
		if(($_POST['pass1']==$_POST['pass2'])){
			$pass=$_POST['pass1'];   }
		  else{
			  $errors[]="Passwords do not match"; }
	  else{ $errors="You forgot to enter password"; }
	}
}
?>

<?php
include("footer.html");
?>

add one more closing ) before { at line 41

if(!empty($_POST['pass1']) ) {

Thanks utrivedi, it solved now I am getting another error :-

Parse error: syntax error, unexpected T_ELSE in C:\xampp\htdocs\register.php on line 46

For those errors it really helps if you format your code more clearly. If you do, you will see that there's a missing } after line 45. You also need to remove the one on line 47.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.