Jump to content

Login form not echoing array of user info

CripDawg

this should echo an array of data that is in the data base along with 'incorrect username or password' but it only echo's Incorrect username or password  

 

user.php

public function find($user = null) {if($user) {$field = (is_numeric($user)) ? 'id' : 'username';$data = $this->_db->get('users', array($field, '=', $user)); if($data->count()) {$this->_data = $data->first();return true;}}} public function login($username = null, $password = null){$user = $this->find($username); print_r($this->_data); return false;}}[/code]

login.php

<?phprequire_once 'core/init.php'; if(Input:: exists()) {if(Token::check(Input::get('token'))) { $validate = new Validate();$validation = $validate->check($_POST, array('username' => array('required' => true),'password' => array('required' => true))); if($validation->passed()) {$user = new User();$login = $user->login(Input::get('password')); if($login) {echo 'Success';}else {echo '<p>Incorrect Username or Password</p>';}  } else {foreach($validate->errors() as $error) {echo $error, '<br>';} }}}?> <form action="" method="post"><div class="field"><label for="username">Username</label><input type="text" name="username" id="username" autocomplete="off"></div> <div class="field"><label for="password">Password</label><input type="password" name="password" id="password" autocomplete="off"></div> <input type="hidden" name="token" value="<?php echo Token::generate(); ?>"><input type="submit" value="Log in"></form>
Link to comment
Share on other sites

Link to post
Share on other sites

$login = $user->login(Input::get('password'));

Looks like you need to pass in the username here as well

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×