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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.