Jump to content

Parse error, unexpected T_IF need help finding


MFE

Recommended Posts

I just started coding in PHP and need helping finding the exact location of the parse error.  The output tells me:

"Parse error: syntax error, unexpected T_IF in ... on line 8"

I know it's not an exact location, but still can't find the syntax mistake.

 

<?php #Script6 - register.php 

require_once('template/config.inc');

$page_title = 'Register;
include ('template/header.html')

if (isset($_POST['submitted'])) {

 require_once ('mysql_connect.php');

 //First Name
 if (eregi ("^[[:alpha:].' -]{2,15}$", stripslashes(trim($_POST['first_name'])))) {
 					 $fn = escape_data($_POST['first_name']);
 } else {
 	 			   $fn = FALSE;
					 echo '<p>Please enter your first name</p>';
 }

 //Last Name
 if (eregi ("^[[:alpha:].' -]{2,30}$", stripslashes(trim($_POST['last_name'])))) {
 					 $ln = escape_data($_POST['last_name']);
 } else {
 	 			   $ln = FALSE;
					 echo '<p>Please enter your last name</p>';
 }

 //Email Address
 if (eregi ("^[[:alnum:]][a-z0-9_.-]*@[a-z0-9.-]+\.[a-z]{2,4}$", stripslashes(trim($_POST['email'])))) {
 					 $e = escape_data($_POST['email']);
 } else {
 	 			   $e = FALSE;
					 echo '<p>Please enter your email address</p>';
 }

 //Username
 if (eregi ("^[[:alnum:]_]{4,20}$", stripslashes(trim($_POST['username'])))) {
 					 $u = escape_data($_POST['username']);
 } else {
 	 			   $u = FALSE;
					 echo '<p>Please enter a valid username</p>';
 }

 //Password
 if (eregi ("^[[:alnum:]]{8,20}$", stripslashes(trim($_POST['password1'])))) {
 		if ($_POST['password1'] == $POST['password2']) {
			 $p = escape_data($_POST['password1']);
		} else {
			 $p = FALSE;
			 echo '<p>Your password did not match the confirmed password</p>';
		}
	} else {
		$p = FALSE;
		echo '<p>Please enter a valid password</p>';
 }

 //EVERYTHING

 if ($fn && $ln && $e && $u && $p) {

 		//Username availability
		$query = "SELECT user_id FROM users WHERE username='$u'";
		$result = @mysql_query ($query);

		if (mysql_num_rows($result) == 0) {

			 //Add user to DB
			 $query = "INSERT INTO users (username, first_name, last_name, email, password, registration_date) VALUES ('$u', '$fn', '$ln', '$e', PASSWORD('$p'), NOW() )";
			 $result = @mysql_query ($query);

			 if ($result){

			 			//Email New User
						$body = "Dear '{$_POST['first_name']}',\n Thank you for registering";
						mail ($_POST['email'], 'Thank you for registering', $body, 'From: [email protected]');

						//Output
						echo 'Thank you for registering';
						include ('template/footer.html');
						exit ();
				} else {
					echo '<p>You could not be registered due to a system error. We apologize for the inconvenience</p>';
				}

		} else {
			echo '<p>That username is already taken. Please choose another.</p>';
		}

		mysql_close();

} else { //if one of the data tests fail
	   echo '<p>Please try again.</p>';
}
}
?>

<h1>Register</h1>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<fieldset>

<p>First Name: <input type="text" name="first_name" value="<?php if (isset($_POST['first_name'])) echo $_POST['first_name']; ?>" /></p>

<p>Last Name: <input type="text" name="last_name" value="<?php if (isset($_POST['last_name'])) echo $_POST['last_name']; ?>" /></p>

<p>Email Address: <input type="text" name="email" value="<?php if (isset($_POST['email'])) echo $_POST['email']; ?>" /></p>

<p>User Name: <input type="text" name="username" value="<?php if (isset($_POST['username'])) echo $_POST['first_name']; ?>" /><span>Use only letters, numbers, and underscore. Must be between 4 and 20 characters long.</span></p>

<p>Password: <input type="password" name="password1" /><span>Use only letters and numbers. Must be between 8 and 20 characters long.</span></p>

<p>Confirm Password: <input type="password" name="password2" /></p>
</fieldset>

<div align="center"><input type="submit" name="submit" value="Register" /> </div>
</form>

<?php
include_once('template/footer.html');
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.