I am working on cakephp 2.x.i have a table in my database name *user* and 
it has 4 fields *id, email, password and mobileNo*

*what i want is i want to login the user from his mobileNo too(if he typed 
mobile number rather then email address) just like facebook has done ..he 
can either login with hi email address or mobileno .i dont want to create 
another input field.. i dont know how can i do this here is my code 
*

i have two fields in my *login.ctp*

<?php


 echo $this->form->create();

echo $this->form->input('email',array('type'=>'text'));//i do this type = text 
because otherwise if i typed number in browser then it gives me error that type 
type email address ... 
echo $this->form->input('password');


echo $this->form->end('submit');
 ?>

*AppController*

class AppController extends Controller {
 public $components = 
array('Session','Auth'=>array('loginRedirect'=>array('controller'=>'users', 
'action'=>'admin'),'logoutRedirect'=>array('controller'=>'users', 
'action'=>'admin'),'authError'=>"You can't access that 
page",'authorize'=>array('Controller'),
  'authenticate' => array(
   'Form' => array(
    'fields' => array('username' => 'email')
    )))
    );
 )
 );

public function isAuthorized($user) {
 }

 public function beforeFilter() {
 $this->Auth->allow('index');
 }}


*UserController*

*
*

*class UsersController extends AppController {
    public function beforeFilter() {
        parent::beforeFilter();



            

        }
    




    public function login() {
        $this->layout='userdefault';
        if ($this->request->is('post')) {

            
            if ($this->Auth->login()) {
                debug($this->Auth->login());
                $this->redirect($this->Auth->redirect());
            } else {
                $this->Session->setFlash('Your username/password combination 
was incorrect');//this will redisplay the login page
            }
        }
    }
*

 

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to