Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Using Auth method for login in cakephp

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 398
    Comment on it

    First of all load the component in the controller lets say UsersController using the below code

    $this->uses=array(Auth);
    

    login.view:

    <?php
    echo $this->Form->create('User', array('id'=>'signUpForm','name'=>'userSignupForm', 'action'=>'login')); ?>
    <dl>
    <dt>User Name:</dt>
    <dd ><?php echo $this->Form->input('User.username', array('type'=>'text',  'label'=>false, 'div'=>false))?></dd>
    
    <dt>Password:</dt>
    <dd><?php echo $this->Form->input('User.password', array( 'type'=>'password','label'=>false, 'div'=>false)); ?></dd>
    </dl>
    <?php echo $this->Form->end('Login'); ?>
    

    Write the code in login action of UsersController:

    $this->Auth->login();
    

    It will return 0= If logged in failed. Otherwise 1 if successfull.

 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: