Welcome Guest, Not a member yet? Register   Sign In
got any ideas on this?
#1

[eluser]mistress_shiira[/eluser]
good day guys!im still new to CI and ive been trying to learn how to use a framework such as this.
im currently redoing an admin page that i have developed without using any framework before.i would like to redo it using CI.unfortunately, i have come across this problem.hope you can tell me how to go about with this.
actually i have this code:
Quote:function index(){
$this->load->library('validation','session');
$this->load->helper('form');
//set validation rules
$rules['username'] = "trim|required|callback_check_input";
$rules['password'] = "trim|required";
$this->validation->set_rules($rules);

//set validation fields
$fields['username'] = "username";
$fields['password'] = "password";
$this->validation->set_fields($fields);

if ($this->validation->run()) {
$query = $this->db->getwhere('users', array('username' => $this->input->post('username')));
$row = $query->row();
$this->load->view('cpats_main');

}
else{

$this->load->view('cpats_admin');
}
}
actually it already works,i can log in and proceed to the next page.the problem is that when i re enter the URL and hit enter,the page goes back to the admin page.how can i avoid it doing that?
#2

[eluser]schnoodles[/eluser]
Im guessing this is a login system, in that case what you want to do is in validation success use session and store something like logged_in=1

so you can do if($this->session->userdata('logged_in')) { //take them to a logged in page }
#3

[eluser]mistress_shiira[/eluser]
[quote author="schnoodles" date="1194511473"]Im guessing this is a login system, in that case what you want to do is in validation success use session and store something like logged_in=1

so you can do if($this->session->userdata('logged_in')) { //take them to a logged in page }[/quote]
heres a pseudocode of what i did:
check if validation->run
set $this->session->set_userdata('logged_in',1);
and load $this->load->view('mainpage');
else
load $this->load->view('loginpage');

i get an error on $this->session->set_userdata though
#4

[eluser]llbbl[/eluser]
if you can wait like another 2 weeks for me, I will release my user authentication system, that is very easy to use. It might save you some work. Smile
#5

[eluser]mistress_shiira[/eluser]
llbbl,uve been a great help! yeah,sure ill wait for that user auth system that ur currently doing.anyways,im not in a hurry.i am in the study mode stage as of now. im trying to redevelop the projects that i did before this time using a framework which is codeigniter.just keep me posted.
#6

[eluser]schnoodles[/eluser]
HawHaw if you wait about 1-3 days ill prob release mine, although its just a bunch of methods so you do the form validation and everything yourself then you just do

$user->login($username,$password);
#7

[eluser]Rick Jolly[/eluser]
[quote author="mistress_shiira" date="1194512010"]
heres a pseudocode of what i did:
check if validation->run
set $this->session->set_userdata('logged_in',1);
and load $this->load->view('mainpage');
else
load $this->load->view('loginpage');

i get an error on $this->session->set_userdata though[/quote]
If you load the session library it should work.
#8

[eluser]llbbl[/eluser]
I need to do a couple things, one of them being make some documentation. I want to add roles (admin,user,whatever) and the appropriate functions. To check for those roles. Right now it does.

- captcha based user registration
- activation w/ link sent to the email used to register with
- forgot password link sent to email, similar to activation, which allows them fill out a form
- login/out form + classes
- uses CI sessions
#9

[eluser]mistress_shiira[/eluser]
i have decided to do this application as an MVC.but theres something thats confusing me.hope you can give me ideas on how to proceed.

i have created a model,controller and a view for this particular exercise.
i want to load first a view file that contains the log in page so in my main controller i call it like this:

Quote: class main_control extends Controller{
function main_control(){
parent::Controller();
}
function index(){
$this->load->view('login_page');
}
}
now,im stuck.:d i dont know how to proceed.after i have load the view for the log in page.what i want to do is to verify the input of the user before they can log in.i dont know where to put that anymore.do i have to do another controller for that?pls help me..
#10

[eluser]llbbl[/eluser]
read the user guide, Validation class.

Also the you need to know how to write your own library file and call functions in the library. You will call a function called register or whatever in your library if the form validates.




Theme © iAndrew 2016 - Forum software by © MyBB