Advertisement
michaelyuen

Untitled

Aug 15th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.95 KB | None | 0 0
  1. // change these value to test your condition;
  2. $bb_name = 'somebank';
  3. $password = '123456';
  4. $confirm = '123456';
  5. $email = 'john@abc.com';
  6. $city = 'some city';
  7. $reg_number = '1234';
  8.  
  9. $check = true;
  10.  
  11. if(empty($bb_name) || empty($city) || empty($reg_number) || empty($email) || empty($password) || empty($confirm)) {
  12.     $check = false;
  13.     $errors[] = 'missing field';
  14. }
  15.  
  16. if (!preg_match('/^[a-zA-Z]+$/',$bb_name)) {
  17.     $check = false;
  18.     $errors[] = 'preg_match failed';
  19. }
  20.  
  21. if (strlen($password) < 5 || $password !== $confirm) {
  22.     $check = false;
  23.     $errors[] = 'password length failed or mismatch';
  24. }
  25.  
  26. if (filter_var($email, FILTER_VALIDATE_EMAIL) === false) {
  27.     $check = false;
  28.     $errors[] = 'invalid email';
  29. }
  30.  
  31. if (!$check) {
  32.     foreach ($errors as $error) {
  33.         echo $error.'<br>';
  34.     }
  35. } else {
  36.     $query="INSERT INTO bank_reg (bank_name,city,number_reg,email,password) VALUES ('$bb_name','$city','$reg_number','$email','".md5($password)."')";
  37.     echo $query;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement