Advertisement
Guest User

Untitled

a guest
Mar 15th, 2019
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. VIEW:
  2. <div id="avatar_gallery">
  3. <h1>Avatars Gallery</h1>
  4.  
  5. {form_open("avatar_gallery/submit")}
  6. <div id="avatar_box_gallery">
  7. <input type="text" name="mess" >
  8. <input type="submit" id="avatar_button_gallery" name="submit" value="Change Avatar" />
  9. </div>
  10. {form_close()}
  11. </div>
  12.  
  13. CONTROLLER:
  14. <?php
  15.  
  16. class avatar_gallery extends MX_Controller
  17. {
  18. public function __construct()
  19. {
  20. parent::__construct();
  21. Modules::run('login/is_logged_in');
  22. $this->load->model('avatar_gallery_model');
  23. }
  24.  
  25. public function index()
  26. {
  27. $data = array(
  28. "user_id" => $this->user->getId(),
  29. "status" => $this->user->getAccountStatus(),
  30. "rows" => $this->avatar_gallery_model->view(),
  31. "text" => htmlspecialchars($this->input->post('mess')),
  32. );
  33.  
  34. // Load the view and pass the data
  35. $content = $this->template->loadPage("avatar_gallery.tpl", $data);
  36.  
  37. // Put the view in a nice content box with a headline
  38. $box = $this->template->box("Account Panel", $content);
  39.  
  40. // Output the view
  41. $this->template->view($box, "modules/ucp/css/avatar.css");
  42. }
  43.  
  44. public function submit()
  45. {
  46. $u_Data = array(
  47. 'avatar' => htmlspecialchars($this->input->post('mess')),
  48. );
  49.  
  50. $this->avatar_gallery_model->get($u_Data);
  51.  
  52. $content = $this->template->loadPage("sent.tpl", $arrData);
  53. $box = $this->template->box("Account Panel", $content);
  54. $this->template->view($box, "modules/ucp/css/avatar.css");
  55. }
  56. }
  57.  
  58. MODEL:
  59. <?php
  60. class avatar_gallery_model extends CI_Model
  61. {
  62. public function get($u_Data)
  63. {
  64. $this->db->update('account_data', $u_Data, array('id' => $this->user->getId()));
  65. }
  66.  
  67. public function view()
  68. {
  69. $query = $this->db->query("SELECT * FROM account_data ORDER BY id DESC");
  70.  
  71. if($query->num_rows())
  72. {
  73. $row = $query->result_array();
  74.  
  75. return $row;
  76. }
  77. else
  78. {
  79. return false;
  80. }
  81. }
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement