Welcome Guest, Not a member yet? Register   Sign In
error entering wrong login details
#1

[eluser]learning_php[/eluser]
Hi,

I have been trying to use a login system from members only access. The system works when the user enter the correct details but if they get it wrong this happens:
Code:
A PHP Error was encountered

Severity: Notice

Message: Undefined property: MAdmins::$sesson

Filename: models/MAdmins.php

Line Number: 20

Fatal error: Call to a member function set_flashdata() on a non-object in C:\xampp\htdocs\wedding-site\system\application\models\MAdmins.php on line 20

Code:
<?PHP
    class MAdmins extends Model{
        
        function MAdmins(){
            
            parent::Model();
        }
        
        function verifyUser($u,$pw){
            $this->db->select('username');
            $this->db->where('username',$u);
            $this->db->where('password',$pw);
            
            $Q = $this->db->get('members');
            if ($Q->num_rows()>0){
                $row = $Q->row_array();
                //$_SESSION['userid'] = $row['ID'];
                $_SESSION['username'] = $row['username'];
            }else{
                $this->sesson->set_flashdata('error','you have enter the wrong details!');
            }
        }
    }
?>
Code:
<?PHP
                    if ($this->session->flashdata('error')){
                        echo "<div id='message'>";
                        echo $this->session->flashdata('error');
                        echo "</div>";
                    }
                    ?&gt;
                    
                    &lt;?PHP
                    $udata = array('name'=>'username','id'=>'u','size'=>15);
                    $pdata = array('name'=>'password','id'=>'p','size'=>15);
                    
                    echo form_open('gallery/verify');
                    echo "<P><label for = 'u'>username</label><br />";
                    echo form_input($udata)."</P>";
                    echo "<P><label for ='p'>password</label><br />";
                    echo form_password($pdata)."</P>";
                    echo form_submit('submit','login');
                    echo form_close();
                    ?&gt;
#2

[eluser]Dam1an[/eluser]
Do you auto load the session library?
#3

[eluser]learning_php[/eluser]
Yea
Code:
$autoload['libraries'] = array('database','session');
#4

[eluser]TheFuzzy0ne[/eluser]
I'm curious. You're using the session class, but apparently trying to use the native PHP sessions also. I'd highly recommend you stick to using $this->session->set_userdata() and $this->session->userdata(). I'm not sure if this will fix your problem, but I do know that mixing native PHP sessions with CodeIgniter's session class is usually a recipe for disaster.
#5

[eluser]juan1904[/eluser]
Probably you've already solved this problem but here we go anyway.

Quote from your code:
Code:
$this->sesson->set_flashdata('error','you have enter the wrong details!');

Correct one:
Code:
$this->session->set_flashdata('error','you have enter the wrong details!');
#6

[eluser]Thorpe Obazee[/eluser]
juan, eagle eyes!

happens all the time Smile




Theme © iAndrew 2016 - Forum software by © MyBB