Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.09 KB | None | 0 0
  1. function ControleGeldigheid($aantalErrors){
  2.        
  3.         //echo "ControleGeldigheid() Started"."<br>";
  4.        
  5.         $errors = array();
  6.        
  7.         $userName = $_POST['user'];
  8.         $email = $_POST['email'];
  9.         $password = $_POST['pass'];
  10.         $cpassword = $_POST['cpass'];
  11.         $mainCharacter = $_POST['mainCharacter'];
  12.        
  13.         //echo "Controle username"."<br>";
  14.        
  15.         if (!preg_match("/^[0-9a-zA-Z ]*$/",$userName)) {
  16.           $errors[] = "Username: Only letters, numbers  and white space allowed. 6-18 characters";
  17.         }
  18.        
  19.         //echo "Controle email"."<br>";
  20.        
  21.         if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
  22.           $errors[] = "Invalid email format";
  23.         }
  24.        
  25.         //echo "Controle passwords"."<br>";
  26.        
  27.         if ($password == $cpassword) {            
  28.             if(!preg_match('/^(?=.*\d)(?=.*[@#\-_$%^&+=§!\?])(?=.*[a-z])(?=.*[A-Z])[0-9A-Za-z@#\-_$%^&+=§!\?]{8,20}$/',$password)) {
  29.                 $errors[] = "Invalid password.<br>Must contain: at least one lowercase char, at least one uppercase char, at least one digit, at least one special sign of @#-_$%^&+=§!?";
  30.             }
  31.         }
  32.         else {
  33.             $errors[] = "Passwords do not match";
  34.         }
  35.        
  36.         //echo "Controle armory link"."<br>";
  37.        
  38.         if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i",$mainCharacter)) {
  39.           $errors[] = "Invalid Character Armory link";
  40.         }
  41.    
  42.         // Tellen van aantal fouten
  43.         $aantalErrors = 0;
  44.         $aantalErrors = $aantalErrors + count($errors);
  45.        
  46.         if($aantalErrors > 0){
  47.            
  48.         echo "<div id='foutBox'><p class='foutLijst'>";
  49.        
  50.             for ($i = 0; $i < count($errors);$i++){
  51.                
  52.                 $errorTeller = $i + 1;
  53.                
  54.                 echo $errors[$i]."<br /><br />";
  55.                
  56.             }
  57.             echo "</div></p>";
  58.         }
  59.        
  60.         return $aantalErrors;
  61.          
  62.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement