Welcome Guest, Not a member yet? Register   Sign In
Model (verify username & password
#31

[eluser]terry101[/eluser]
ok i have taken off the manual load database.

Model --- i added this $this->output->enable_profiler(1); before the error line
Code:
<?php

class Loginmodel extends CI_Model {
    
    function check_login ($username, $password) {
        $en_password = MD5($password);
                
        $checklogin = array('username' => $username, 'password' => $password);
        $verifylogin = $this->db->get_where('tbregister',$checklogin);
        var_dump($verifylogin);
        $this->output->enable_profiler(1);
        if ($verifylogin->num_row == 1) {
            
            return TRUE;
        }
        else {
            
            return FALSE;
        }
    }
}


this is what outputs, what exactly are we looking for in here? this may help in the future as well.


object(CI_DB_mysql_result)[17]
public 'conn_id' => resource(29, mysql link persistent)
public 'result_id' => resource(34, mysql result)
public 'result_array' =>
array
empty
public 'result_object' =>
array
empty
public 'custom_result_object' =>
array
empty
public 'current_row' => int 0
public 'num_rows' => int 1
public 'row_data' => null
A PHP Error was encountered

Severity: Notice

Message: Undefined property: CI_DB_mysql_result::$num_row

Filename: models/loginmodel.php

Line Number: 12

Username or password is invalid, try again
BENCHMARKS
Loading Time: Base Classes 0.0176
Controller Execution Time ( Userlogin / Login ) 0.0317
Total Execution Time 0.0494
GET DATA
No GET data exists
MEMORY USAGE
4,536,304 bytes
POST DATA
$_POST['username'] johnny
$_POST['password'] hello
$_POST['submit'] login
URI STRING
userlogin/login
CLASS/METHOD
userlogin/login
DATABASE: blog QUERIES: 1
0.0004 SELECT *
FROM (`tbregister`)
WHERE `username` = 'johnny'
AND `password` = 'hello'
HTTP HEADERS
HTTP_ACCEPT text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
HTTP_USER_AGENT Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.107 Safari/535.1
HTTP_CONNECTION keep-alive
SERVER_PORT 80
SERVER_NAME localhost
REMOTE_ADDR 127.0.0.1
SERVER_SOFTWARE Apache/2.2.17 (Win32) PHP/5.3.4
HTTP_ACCEPT_LANGUAGE en-US,en;q=0.8
SCRIPT_NAME /codetwo/index.php
REQUEST_METHOD POST
HTTP_HOST
REMOTE_HOST
CONTENT_TYPE application/x-www-form-urlencoded
SERVER_PROTOCOL HTTP/1.1
QUERY_STRING
HTTP_ACCEPT_ENCODING gzip,deflate,sdch
HTTP_X_FORWARDED_FOR
CONFIG VARIABLES
base_url http://localhost/codetwo/
index_page index.php
uri_protocol AUTO
url_suffix
language english
charset UTF-8
enable_hooks
subclass_prefix MY_
permitted_uri_chars a-z 0-9~%.:_\-
allow_get_array 1
enable_query_strings
controller_trigger c
function_trigger m
directory_trigger d
log_threshold 0
log_path
log_date_format Y-m-d H:iConfused
cache_path
encryption_key
sess_cookie_name ci_session
sess_expiration 7200
sess_expire_on_close
sess_encrypt_cookie
sess_use_database
sess_table_name ci_sessions
sess_match_ip
sess_match_useragent 1
sess_time_to_update 300
cookie_prefix
cookie_domain
cookie_path /
cookie_secure
global_xss_filtering
csrf_protection
csrf_token_name csrf_test_name
csrf_cookie_name csrf_cookie_name
csrf_expire 7200
compress_output
time_reference local
rewrite_short_tags
proxy_ips
#32

[eluser]CodeIgniteMe[/eluser]
aha.. look at the database query.
1. It searches the 'tbregister' table with username 'johnny' and passsword 'hello' (which should be encrypted), use $en_password instead of $password
2. Are the passwords in the database encrypted?
3. revert the $verifylogin->num_rows to $verifylogin->num_rows()
4. and I found what was wrong.
-- num_row (notice the difference with num_rows) is not a method or property of the database class
-- this should work now
#33

[eluser]terry101[/eluser]
Perfect!!! it worked. it was the num_rows. Thanks for assisting!!!
#34

[eluser]CodeIgniteMe[/eluser]
[quote author="terry101" date="1312826565"]Perfect!!! it worked. it was the num_rows. Thanks for assisting!!![/quote]

your welcome




Theme © iAndrew 2016 - Forum software by © MyBB