Advertisement
Guest User

create-account-action

a guest
Jun 28th, 2019
822
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.18 KB | None | 0 0
  1. <?php
  2.  
  3. include "../inc/account-manager.inc.php";
  4.  
  5. if(isset($_POST['email'])
  6.     && isset($_POST['username'])
  7.     && isset($_POST['password'])
  8.     && isset($_POST['confirm_password'])){
  9.        
  10.     $username = $_POST['username'];
  11.     if(strlen($username) >= 32){
  12.         header("Location: ./create-account.php?msg=uname_long");
  13.     }
  14.    
  15.     if(user_exists($username)){
  16.         header("Location: ./create-account.php?msg=user_exists");
  17.     }else{
  18.        
  19.         $email = $_POST['email'];
  20.         if(email_in_use($email)){
  21.             header("Location: ./create-account.php?msg=email");
  22.         }else{
  23.             $password = $_POST['password'];
  24.             if($password != $_POST['confirm_password']){
  25.                 header("Location: ./create-account.php?msg=password_match");
  26.             }else{
  27.            
  28.                 $last_name = isset($_POST['last_name']) ? $_POST['last_name'] : null;
  29.                 $first_name = isset($_POST['first_name']) ? $_POST['first_name'] : null;
  30.                 $birthday = isset($_POST['birthday']) ? $_POST['birthday'] : null;
  31.                
  32.                 if(create_account($email, $username, $password, $last_name, $first_name, $birthday)){
  33.                     header("Location: ./create-account.php?msg=account_created");
  34.                 }else{
  35.                     header("Location: ./create-account.php?msg=error");
  36.                 }
  37.             }
  38.         }
  39.        
  40.     }
  41.    
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement