Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function RegisterUser()
- {
- if(!isset($_POST['submitted']))
- {
- return false;
- }
- $formvars = array();
- if(!$this->ValidateRegistrationSubmission())
- {
- return false;
- }
- $this->CollectRegistrationSubmission($formvars);
- if(!$this->SaveToDatabase($formvars))
- {
- return false;
- }
- /*if(!$this->SendUserConfirmationEmail($formvars))
- {
- return false;
- }*/
- $this->SendAdminIntimationEmail($formvars);
- $this->AutoLogin($formvars);// My call
- return true;
- }
- function Login()
- {
- if(empty($_POST['email']))
- {
- $this->HandleError("Email is empty!");
- return false;
- }
- if(empty($_POST['password']))
- {
- $this->HandleError("Password is empty!");
- return false;
- }
- $email = trim($_POST['email']);
- $password = trim($_POST['password']);
- if(!isset($_SESSION)){ session_start(); }
- if(!$this->CheckLoginInDB($email,$password))
- {
- return false;
- }
- $_SESSION[$this->GetLoginSessionVar()] = $email;
- return true;
- }
- function AutoLogin(&$formvars)
- {
- $email = trim($formvars['email']);
- $password = trim($formvars['password']);
- if(!isset($_SESSION)){ session_start(); }
- if(!$this->CheckLoginInDB($email,$password))
- {
- return false;
- }
- $_SESSION[$this->GetLoginSessionVar()] = $email;
- return true;
- }
- function CheckLogin()
- {
- if(!isset($_SESSION)){ session_start(); }
- $sessionvar = $this->GetLoginSessionVar();
- if(empty($_SESSION[$sessionvar]))
- {
- return false;
- }
- return true;
- }
- function CheckLoginInDB($email,$password)
- {
- if(!$this->DBLogin())
- {
- $this->HandleError("Database login failed!");
- return false;
- }
- $email = $this->SanitizeForSQL($email);
- $pwdmd5 = md5($password);
- $qry = "Select name, email, pagecode, welcome from $this->tablename where email='$email' and password='$pwdmd5' and confirmcode='y'";
- $result = mysql_query($qry,$this->connection);
- if(!$result || mysql_num_rows($result) <= 0)
- {
- $this->HandleError("Error logging in. The email or password does not match");
- return false;
- }
- $row = mysql_fetch_assoc($result);
- $_SESSION['name_of_user'] = $row['name'];
- $_SESSION['email_of_user'] = $row['email'];
- $_SESSION['pagecode_of_user'] = $row['pagecode'];
- $_SESSION['welcome_user'] = $row['welcome'];
- return true;
- }
- function GetLoginSessionVar()
- {
- $retvar = md5($this->rand_key);
- $retvar = 'usr_'.substr($retvar,0,10);
- return $retvar;
- }
- <?php
- if (!$_SESSION) {
- session_start();
- }
- $currentUser = array();
- function getUserFromID($userID)
- {
- //TODO implement function
- return $user;
- }
- function AutoLogin()
- {
- global $currentUser;
- if(!empty($_SESSION['userID'])) {
- return false;
- }
- $user = getUserFromID($_SESSION['userID']);
- if (empty($user)) {
- return false;
- }
- $currentUser = $user;
- return true;
- }
Add Comment
Please, Sign In to add comment