Jump to content

Need help with validating a form - Error msg


boblan66

Recommended Posts

I am debugging a PHP file that validates a user registration form. I'm very confused on this error message I'm receiving.

 

( Parse error: syntax error, unexpected '[' in C:\wamp\www\reg.php on line 17 )

 

I have looked until I cross-eyed to finf the syntax error. Here is a copy of my code:

<?php 

// Post registration to database
// Connects to your Database 
$userName = "taft65_admin";
$passWord = "taft65_paris4505";
$host="localhost";
$dbName = "taft65_members";

mysql_connect("dbName", "userName", "passWoord", "host") or die(mysql_error()); 
mysql_select_db("dbn") or die(mysql_error()); 

//This code runs if the form has been submitted
if (isset($_POST['submit'])) { 

[color=yellow]//This makes sure they did not leave any fields blank
if (!$_POST['id'] | !_POST['userName'] | !$_POST['passWord'] | !$_POST['confpassWord'] | !$_POST['email'] ) {
		die('You did not complete all of the required fields');
	}[/color]

// checks if the userName is in use
	if (!get_magic_quotes_gpc()) {
		$_POST['userName'] = addslashes($_POST['userName']);
	}
$usercheck = $_POST['userName'];
$check = mysql_query("SELECT userName FROM users WHERE userName = '$usercheck'") 
or die(mysql_error());
$check2 = mysql_num_rows($check);

//if the name exists it gives an error
if ($check2 != 0) {
		die('Sorry, the userName '.$_POST['userName'].' is already in use.');
				}
// 
this makes sure both passWoords entered match
	if ($_POST['passWord'] != $_POST['ConfPassWord']) {
		die('Your passWoords did not match. ');
	}

	// here we encrypt the passWord and add slashes if needed
	$_POST['passWord'] = md5($_POST['passWord']);
	if (!get_magic_quotes_gpc()) {
		$_POST['passWord'] = addslashes($_POST['passWord']);
		$_POST['userName'] = addslashes($_POST['userName']);
			}

// now we insert it into the database
	$insert = "INSERT INTO registration (userName, passWord, email )
			VALUES ('".$_POST['userName']."', '".$_POST['passWord'].", '".$_POST['email']."')";
	$add_member = mysql_query($insert);

?>

<p>Thank you, you have successfully registered.  
<a href="memPage.html"></a>you may now login.</p>

 

Can someone help me with this by checking the code and tell me where I wen in error.

 

BobLan66

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.