php - Form validation - security -


so i'm working on register form , have 4 fields: name, username, email , password. pick values of these fields in jquery , depending on if fields filled, pass them onto php script via ajax. safe form validations? worried data getting manipulated user.

further on in php script, check if posted values have data in them, proceed onto doing validations... validations parts i'm worried it's not best , there many flaws it.

    $name = $_post['name'];     $username = $_post['username'];     $email = $_post['email'];     $password = $_post['password'];   if (!preg_match("/^[a-za-z '-]+$/i", $name)) {          $errors = "please enter valid name.";      } else if (!preg_match("/^[a-za-z]+\s[a-za-z]+$/", $name)) {          $errors = "please enter first , last name.";      } else if (strlen($username) <= 3 || strlen($username) > 15) {          $errors = "please pick username between 4 - 15 characters. creative.";      } else if (!preg_match("/^[a-za-z][a-za-z0-9_.-]{4,15}$/", $username)) {          $errors = "please pick alphanumeric username between 4 - 15 characters.";      } else if (filter_var($email, filter_validate_email) === false) {          $errors = "please enter valid email.";      } else if (strlen($username )< 6 || strlen($username) > 32) {          $errors = "your password must atleast 6 characters.";      } else {          echo "valid";      } 

are these validation steps secure? there loop holes user can manipulate data? also, hoping full name input, user input first , last name. these enough?

thank you.

as asked review, pls read wrote here...

} else if (strlen($username )< 6 || strlen($username) > 32) {     $errors = "your password must atleast 6 characters." 

Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -