Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to login in Cakephp using Email and Password or Username and Password

    • 0
    • 1
    • 1
    • 1
    • 0
    • 0
    • 0
    • 0
    • 873
    Comment on it

    Hello Readers,

    If you want to login the cakephp application using the email or username and password

    Use the below code:

    $username=$REQUEST['login'];
    $email=$REQUEST['login'];
    $password=$REQUEST['password'];
    Here $REQUEST be the superglobal variable
     if($email && $password){
          $user = $this->User->find("first", array(
                                  "conditions" => array(
                                  "User.email" => $email,"User.password"=>$password
                                      )
    
                              )
                          );
                      }
              elseif($username && $pass){
          $user = $this->User->find("first", array(
                                  "conditions" => array(
                                  "User.username" => $username,"User.password"=>$password
                                      )
    
                              )
                          );
                      }
    

    The above code contain the email, username and password to login the application. And here we have used the find Method to filter the record according to email or username and password and using the if and elseif condition to check the user and password to login the application

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: