Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(isset($_POST["username"])) {
- $username = $_POST["username"];
- } else {
- die("Invalid request");
- }
- if(isset($_POST["password"])) {
- $password = $_POST["password"];
- } else {
- die("Invalid request");
- }
- if(isset($_POST["confirm_password"])) {
- $confirm_password = $_POST["confirm_password"];
- } else {
- die("Invalid request");
- }
- if(isset($_POST["email"])) {
- $email = $_POST["email"];
- } else {
- die("Invalid request");
- }
- $errors = array();
- echo "Hello, ".$username."<br>";
- echo "Length: ".strlen($username)."<br>";
- if(!(strlen($username)>=3 && strlen($username)<=30)) {
- $errors[] = "The username should be between 3 and 30 characters";
- }
- if(!(strlen($password)>=6 && strlen($password)<=30)) {
- $errors[] = "The password should be between 6 and 30 characters";
- $errors[] = "The password should be between 6 and 30 characters";
- }
- if($password!=$confirm_password) {
- $errors[] = "The passwords do not match";
- }
- if (filter_var($email, FILTER_VALIDATE_EMAIL)==false) {
- $errors[] = "The email is not valid!";
- }
- if(count($errors)>0) {
- foreach($errors as $error) {
- echo "ERROR: ".$error."<br>";
- }
- } else {
- echo "OK";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement