Welcome Guest, Not a member yet? Register   Sign In
[help]School Project Here
#11

[eluser]miwrath[/eluser]
thank you so much...

im gonna do that right away...

Smile

sir...
#12

[eluser]miwrath[/eluser]
Code:
<?php

class Registrar extends Controller {

    function Registrar()
    {
        parent::Controller();    
    }
    
    function index()
    {
            $this->login();
                    
    }
        
        function secondary_page()
        {
            
        }
        
        
        function main_page()
        {
            if ($this->session->userdata('logged_in'))
            {
                echo 'you are now logged in' ;
                
            }          
            
            else
            {
                redirect('index.php/user/login');
            }
            
          
            
            
        }
        
        function login()
        {
            $this->form_validation->set_rules('username', 'Username', 'required|trim|max_length[50]|xss_clean');
            $this->form_validation->set_rules('password', 'Password', 'required|trim|max_length[200]|xss_clean');
                                
                    
            if ($this->form_validation->run() == FALSE)
            {
                $this->load->view('view_registrar');
            }
            else
            {
                //echo 'You are great!';
                //process the input and login the user;
                
                /*$sername = $_POST('username');
                $username = $this->input->post('username');
                $password = $_POST('password');
                $password = $this->input->post('password');
                */
               extract($_POST);
            
               $teach_id = $this->User_model->check_login($username, $password);
              
               if (! $teach_id)
               {
                   //login failed error
                  
                   $this->session->set_flashdata('login_error', TRUE);
                  
                   redirect('index.php');
               }
               else
               {
                   //login

                   $this->session->set_userdata(array(
                                           'logged_in' => TRUE,
                                           'teach_id' => $teach_id
                                                     ));
                  
                   redirect('index.php/registrar/main_page');
                  
               }
                
            }
                  
        }
        
}

?>


any one can help me...for this one...

:down:
#13

[eluser]davidbehler[/eluser]
And what exactly doesn't work?
#14

[eluser]miwrath[/eluser]
i cannot proceed to the redirect function...
:down:

i think my authentication process is bad...
#15

[eluser]davidbehler[/eluser]
A couple of things I noticed so far:
1. redirect() doesn't require the index.php, just use the uri string:
Code:
redirect('registrar/main_page');
2. I would switch the order of the validation rules and run trim() before the required rule is run:
Code:
$this->form_validation->set_rules('username', 'Username', 'trim|required|max_length[50]|xss_clean');
3. Why do you use extract()? Definetly not needed, just access the $_POST array directly or use the post method of the input class:
Code:
$username = $_POST['username'];
// or
$username = $this->input->post('username');

And your error description doesn't help at all. Have you tried to debug your code by adding some echos? E.g. after the validation is run, after the check_login method is called? What does "i cannot proceed to the redirect function…" mean anyway? What happens instead?
#16

[eluser]miwrath[/eluser]
it goes back again to the login page...
the database has the account but when i try to login...
the account cannot login...


thank you so much...


next thing to do is my registration form...
another auth form...

:down:
#17

[eluser]davidbehler[/eluser]
Dude, did you try adding some debug code?

Anyway, that means your check_login method can't find the user with the provided username/password.
Add this in your model after your query has run before you return anything to the controler:
Code:
echo $this->db->last_query();
exit();
That should give you the query string you just ran and you can take it and run it yourself in phpmyadmin. Maybe then you'll see why it doesn't work/doesn't return the user you claim is in the database.
#18

[eluser]miwrath[/eluser]
Code:
UPDATE `users` SET `last_activity` = 1313725176, `user_data` = '' WHERE `session_id` = 'ad0587c01a8c6bb737f410c742c6d0b8'

i got this one...what should i do next???
im so sorry im so noob...

Sad

and last time i set my users table with new fields like, ip_adress, last_activity, session_id
but i didnt use those field names in authentication...

do i have to put it in the login checking function?

Sick
#19

[eluser]davidbehler[/eluser]
Alright. So what exactly are you trying to do?
You have the user submit a form where he enters his username and passwort. Then what? Please show me the code for the model again.
#20

[eluser]miwrath[/eluser]
first i did the login form auth...
input data in the database and try to use it in the login but it doesnt work...
the user submit a form where they enter their username & password ====== so that they can now go to the
MAIN_PAGE where they can have the grades computation system...after they computed the grades they may now
save it to the database for the future purposes...

hope thats clear dude...



i didnt work on the registration so that my work would be faster if i focus on the
hardest auth part of the project.




Theme © iAndrew 2016 - Forum software by © MyBB