checkArrayValues($_POST); die(); $login_err=""; $emailid = trim($_POST['email']); $password = trim($_POST['password']); // create cookie for remember me functionality if(isset($_POST['rememberMe']) && $_POST['rememberMe'] == '1') { setcookie("cookie_email", $emailid, time()+ (10 * 365 * 24 * 60 * 60)); setcookie("cookie_password", $password, time()+ (10 * 365 * 24 * 60 * 60)); } if((isset($_POST['selectRole']) && $_POST['selectRole'] == '') || !isset($_POST['selectRole'])){ // email in upper case validation if (preg_match("/[A-Z]/",$emailid)) { $login_err="Provide E-mail in lower case."; } else { // validate login authentication for super admin $login_auth=$common->checkIsValidLogin($emailid,$password,1); if($login_auth == 0) { $login_err="Please select login type"; } else if($login_auth == 1){ //get user_id using email id $user_id=$common->getUseridFromEmailid($emailid,1); $_SESSION['role_id'] = 1; $_SESSION['user_id'] = $user_id; $_SESSION['email_id'] = $emailid; // successful login - redirect to dashboard page header("Location: home.php"); } else { $login_err="Please select login type"; } } } else { // email in upper case validation if (preg_match("/[A-Z]/",$emailid)) { $login_err="Provide E-mail in lower case."; } else { $role_id = $common->getRoleIdFromRoleName(trim($_POST['selectRole'])); if($role_id == 3){ // Login With Branch Manager // validate login authentication for branch manager $login_auth=$common->checkBranchValidLogin($emailid,md5($password)); if($login_auth['valid_login'] == 0) { $login_err="Oops! The combination of emailid and password does not exist Or Please select valid login type, Please try again!"; } else if($login_auth['valid_login'] == 1 && $login_auth['branch_subscription_plan_active'] == 0) { $login_err="Please activate branch subscription plan."; } else { $_SESSION['branch_id'] = $login_auth['branch_id']; $_SESSION['email_id'] = $emailid; $_SESSION['role_id'] = $role_id; // successful login - redirect to branch home page header("Location: codesearch.php"); } } else { // Login With Marketing Manager // validate login authentication for marketing manager $login_auth=$common->checkIsValidLogin($emailid,md5($password),$role_id); if($login_auth == 0) { $login_err="Oops! The combination of emailid and password does not exist. Please try again!"; } else { //get user_id using email id $user_id=$common->getUseridFromEmailid($emailid,$role_id); $user_id=trim($user_id); $_SESSION['user_id'] = $user_id; $_SESSION['email_id'] = $emailid; $_SESSION['role_id'] = $role_id; // if login user id marketing manager and no any branch created than redirect add new location page $num_of_branch = $common->countUserBranchCreated($_SESSION['user_id']); if($num_of_branch == 0){ // successful login - redirect to dashboard page header("Location: branch_create.php"); } else { // successful login - redirect to dashboard page header("Location: home.php"); } } } } } } if (isset($_COOKIE['cookie_email']) && $_COOKIE['cookie_email']!='') { $emailid = $_COOKIE['cookie_email']; } if (isset($_COOKIE['cookie_password']) && $_COOKIE['cookie_password']!='') { $password = $_COOKIE['cookie_password']; } ?> Yoloperks