Advertisement
pgeeweb

29.11.2016 - register.php

Nov 29th, 2016
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.17 KB | None | 0 0
  1. <?php
  2. if(isset($_POST["username"])) {
  3.     $username = $_POST["username"];
  4. } else {
  5.     die("Invalid request");
  6. }
  7.  
  8. if(isset($_POST["password"])) {
  9.     $password = $_POST["password"];
  10. } else {
  11.     die("Invalid request");
  12. }
  13.  
  14. if(isset($_POST["confirm_password"])) {
  15.     $confirm_password = $_POST["confirm_password"];
  16. } else {
  17.     die("Invalid request");
  18. }
  19.  
  20. if(isset($_POST["email"])) {
  21.     $email = $_POST["email"];
  22. } else {
  23.     die("Invalid request");
  24. }
  25.  
  26.  
  27. $errors = array();
  28.  
  29. echo "Hello, ".$username."<br>";
  30. echo "Length: ".strlen($username)."<br>";
  31.  
  32. if(!(strlen($username)>=3 && strlen($username)<=30)) {
  33.     $errors[] = "The username should be between 3 and 30 characters";
  34. }
  35.  
  36. if(!(strlen($password)>=6 && strlen($password)<=30)) {
  37.     $errors[] = "The password should be between 6 and 30 characters";
  38.     $errors[] = "The password should be between 6 and 30 characters";
  39. }
  40.  
  41. if($password!=$confirm_password) {
  42.     $errors[] = "The passwords do not match";
  43. }
  44.  
  45.  if (filter_var($email, FILTER_VALIDATE_EMAIL)==false) {
  46.     $errors[] = "The email is not valid!";
  47.  }
  48.  
  49. if(count($errors)>0) {
  50.     foreach($errors as $error) {
  51.         echo "ERROR: ".$error."<br>";
  52.     }
  53. } else {
  54.     echo "OK";
  55. }
  56. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement