Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] coding problem
#1

[eluser]Thorpe Obazee[/eluser]
oK. I am having a problem with my code. I am trying to echo a "true". So far I cannot echo a "true" here. There must be something that I am doing wrong :|

Code:
class Loan extends Controller {

  function Loan(){
    parent::Controller();
  }
  function auth(){
    if ($this->input->post('submit')){
      $u = $this->input->post('u');
      $p = $this->input->post('p');
      
      $this->load->model('loan_model');
      
      $query = $this->loan_model->auth($u,$p);
      
      if ($query->num_rows() > 0){
        echo 'true';
      }else{
        echo 'false';
      }  
    }else{
      $this->load->view('auth_view');
    }
  }

}

model:

Code:
<?php
class Loan_model extends Model {
    
  function Loan_model() {
    #call to Model constructor
    parent::Model();  
  }
  function auth($u, $p){
    $auth_query = $this->db->query("SELECT username, password FROM users WHERE username = '".$u."' AND password = '".$p."'");
    
    return $auth_query;
  }
}
#2

[eluser]webthink[/eluser]
Looks good to me... Try getting the output from $this->db->last_query() then running it manually to see why the query isn't returning results.
#3

[eluser]wiredesignz[/eluser]
That's a very distracting avatar man. :lol:

Where is the code failing? Does the Controller echo "false"? Try print_r($query) to see the Model results.
#4

[eluser]Thorpe Obazee[/eluser]
Yep it gives me a false on every thing even the right username and password. I will try testign a little bit.

Edit: oK. I think I made a booboo. I was trying a wrong username and password. It turns out that I thought I was entering the right username and password.




Theme © iAndrew 2016 - Forum software by © MyBB