Jump to content

simple but i am having a brain fart


grabenair

Recommended Posts

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 by grabenair
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

Loading...
×
×
  • Create New...