how to handle multiple controller by single controller |
[eluser]Beg_student[/eluser]
i have 5 controllers 1.user login(action) 2.member area(Member) 3.Customer(menu of member area) 4.item(menu of member area) 5.payments(menu of member area)
[eluser]PhilTem[/eluser]
Cool, I have like at least 20 of them in one project. How 'bout the others? How many do they have? Sorry for being sarcastic, but what exactly is the question/issue/problem of your thread? I don't really see anything I could give a matching answer for (nope, not even your thread title helps me). And I think others have the same feeling So please, be a little more specific for that we can help you even better!
[eluser]Beg_student[/eluser]
first of thanks for your responce!! here is my problem 1.Action is my default controller and its funnction index() i called login.php and after posting the page my controller is redirect to member area and in member area i develop horizontal css menu and on click i call <li>customer</li> i want to when i click payments its redirect to Payments controller becuase in payments have two tabies 1.view all record 2.add customer but the problem which i face that when i redirect(‘customer’) then url is going to change http://localhost:90/BWebSite/site/Custom...er(method) to http://localhost:90/BWebSite/customer//c...ontroller) can any one give me idea, what should i do for that’s problem? here is my code default controller class Action extends CI_Controller { function __construct() { parent::__construct(); } function index() { $this->load->view(‘login’); } function login() { $this->form_validation->set_rules(‘txtuser’,‘User Name ‘,‘trim|requeried|xss_clean’); $this->form_validation->set_rules(‘password’,‘Password ‘,‘trim|requeried|xss_clean’); $this->load->Model(‘Site_model’); //$this->Site_model->index(); if($this->form_validation->run()==FALSE) { $this->index(); } else { extract($_POST); $user_id = $this->Site_model->check_login($txtuser, $password); if (! $user_id){ // login failed error $this->session->set_flashdata(‘login_error’, TRUE); redirect(‘action/login’); //redirect(‘user/login’); } else { $this->session->set_userdata(array( ‘logged_in’ => TRUE, ‘user_id’ => $user_id )); redirect(‘action/men’); } } } function men() { if ($this->session->userdata(‘logged_in’)) { redirect(‘site’); } } function logout() { $this->session->set_userdata(‘logged_in’,FALSE); } } ?> <?php if ( ! defined(‘BASEPATH’)) exit(‘No direct script access allowed’); class Site extends CI_Controller { public function index() { $this->Customer(); } public function Customer() { $this->load->model(“Site_model”); redirect(‘customer’,current_url());//here is my issue $this->load->view(“Site_header”); $this->load->view(“site_nav”); $this->load->view(“view_customer”); $this->load->view(“site_footer”); } } my model <?php class Site_model extends CI_Model { function check_login($username, $password) { $sha1_password = md5($password); $query_str = “SELECT user_id FROM users WHERE username = ? and password = ?”; $result = $this->db->query($query_str, array($username, $sha1_password)); if ($result->num_rows() == 1) { return $result->row(0)->user_id; } else { return false; } } } ?> hopefully you’ll understand my code thanks
[eluser]PhilTem[/eluser]
It seems like you're using the redirect function incorrectly. Change the line you marked with //here is my issue to Code: redirect('customer'); to redirect to www.example.com/index.php/customer. Please elaborate what the second argument current_url() was supposed to be there for (as well as why you wanted to use a second argument).
[eluser]Beg_student[/eluser]
I am going to explain its very briefly i am going develop simple invoice system i develop login form which is call on my default ACtion controller then after post the page the controller is redirect to my Site controller and in site controller i develop horizontal menu bar the menu bar have and on click i call Code: <li><a href="<?php echo base_url();?>site/Payments">Payments</a></li> Code: public function Customer() shortly what should i do in this problem means how i redirect on menu click? sorry for bad english i want to send my source code ,hopefully you'll better understand my problem Thanks
[eluser]Beginers[/eluser]
your questions are not detailed i can't help you. hard to analyze the point
[eluser]Beg_student[/eluser]
i'll try to explain explain it by School Mangement system ->login these boths are horizontal menu bar Code: [b]ClassSetup[/b] Code: [b]StudentSetup [/b] similarly for student getting friend?:red: |
Welcome Guest, Not a member yet? Register Sign In |