Guest User

Untitled

a guest
Jan 24th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. class Home extends CI_Controller {
  2. public function index() {
  3. if ($this->session->userdata('is_logged_in')==FALSE) {
  4. redirect('Signin/signin');
  5. } else {
  6. $this->customers();
  7. }
  8. }
  9. public function customers(){
  10. // More code here
  11. }
  12. }
  13.  
  14. class Home extends CI_Controller {
  15. public function index() {
  16. if ($this->session->userdata('is_logged_in')==FALSE) {
  17. redirect('Signin/signin');
  18. } else {
  19. $this->customers();
  20. $this->create();
  21. $this->save();
  22. $this->edit($customer_id);
  23. $this->update($customer_id);
  24. $this->delete($customer_id);
  25. }
  26. }
  27. public function customers(){
  28. // More code here
  29. }
  30. public function edit($customer_id){
  31. // More code here
  32. }
  33. /* The rest of
  34. the functions
  35. here */
  36. }
  37.  
  38. class Home extends CI_Controller {
  39. public function __construct(){
  40. parent::__construct();
  41.  
  42. //instead of checking the user whether he is logged in, in every function, check it in the constructor
  43. if (!$this->session->userdata('is_logged_in')) {
  44. redirect('Signin/signin');
  45. }
  46. }
  47.  
  48. //function to show customer lists
  49. public function index() {
  50. $this->load->view('customer_list_view');
  51. }
  52.  
  53. Now if the user wants to add a customer, add a function to show the form
  54. //customer add form view
  55. public function add_customer(){
  56. //show form view
  57. $this->load->view('customer_list_view');
  58. }
  59.  
  60. //save customer
  61. public function save_customer(){
  62. //save or update based the availability of the user to the database
  63. }
  64.  
  65. //delete customer
  66. public function delete_customer(){
  67. //delete the customer here
  68. }
Add Comment
Please, Sign In to add comment