grabenair Posted July 31, 2012 Report Share Posted July 31, 2012 (edited) I am writing a custom CMC to have a template. I came across this problem, when I try to code the password for it can not be over 20 characters in length I keep getting errors no matter how I change it up. I do not want to write another if statement just for that, although that works. What I am looking for is less then 6 but no more then 20. If I use && or || it tell's me Parse error: syntax error, unexpected '>' in C:\xampp\htdocs\cms\register.php on line 21 <?php include 'core/init.php'; include 'includes/overall/header.php'; if (empty($_POST) === false) { $requried_fields = array('username', 'password', 'password_again', 'first_name', 'email'); foreach($_POST as $key=>$value) { if(empty($value) && in_array($key, $requried_fields) === true) { $errors[] = 'Fields marked with an asterisk are requried.'; break 1; } } if (empty($errors) === true) { if (user_exists($_POST['username']) === true) { $errors[] = 'Sorry, the username \'' . $_POST['username'] . '\' is already taken.'; } if(preg_match("/\\s/", $_POST['username']) == true) { $errors[] = 'Your user name must cotain any spaces\.'; } ERROR HERE-> if (strlen($_POST['password']) <6 || >20) { $errors[] = 'Your password must be a least 6 character\'s in length and no more the 20.'; } if ($_POST['password'] != $_POST['password_again']) { $errors[] = 'Your passwords do not match.'; } if(filter_var($_POST['email']. FILTER_VALIDATE_EMAIL) === false) { $ERRORS[] = 'A valid email address is requird. Your privacy is inportant to us. We will not give or sell it to anyone. '; } if(email_exist($_POST['email']) === true){ $errors[] = 'Sorry, the email \'' . $_POST['email'] . '\' is already taken.'; } } } print_r($errors); ?> <h1>Register for the site.</h1> <form action="" method="post"> <ul> <li> Username*:<br> <input type="text" name="username"> </li> <li> Password*:<br> <input type="password" name="password"> </li> <li> Password again*:<br> <input type="password" name="password_again"> </li> <li> First Name*:</br> <input type="text" name="first_name"> </li> <li>Last Name:<br> <input type="text" name="last_name"> </li> <li> Your E-Mail:<br> <input type="text" name="email"> </li> <li> <input type="submit" value="Register"> </li> </ul> </form> <?php include 'includes/overall/footer.php';?> Edited July 31, 2012 by grabenair Quote Link to comment Share on other sites More sharing options...
falkencreative Posted July 31, 2012 Report Share Posted July 31, 2012 You can't do this, since "|| > 20" isn't a complete statement: ERROR HERE-> if (strlen($_POST['password']) <6 || >20) { it has to be split up like this: if (strlen($_POST['password']) < 6 || strlen($_POST['password']) > 20) Quote Link to comment Share on other sites More sharing options...
grabenair Posted July 31, 2012 Author Report Share Posted July 31, 2012 Thanks I was doing this if (strlen($_POST['password']) < 6 || (strlen($_POST['password'])) > 20) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.