Advertisement
Guest User

Untitled

a guest
Feb 10th, 2016
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.32 KB | None | 0 0
  1. Controller: Users.php:
  2.  
  3. <?php
  4. session_start();
  5. class Users extends CI_Controller
  6. {
  7.  
  8. public function viewinsert1()
  9. {
  10.  
  11. $this->load->view('createfinal');
  12. }
  13.  
  14. public function viewinsert2()
  15. {
  16.  
  17. $this->load->library('form_validation');
  18. $this->form_validation->set_rules('email', 'email', 'trim|required|valid_email|xss_clean');
  19. $this->load->view('personalfinal');
  20. }
  21.  
  22. public function viewinsert3()
  23. {
  24.  
  25. $this->load->view('socialfinal');
  26. }
  27.  
  28. public function viewupdate()
  29. {
  30.  
  31. $this->load->view('view_update');
  32. }
  33.  
  34. public function viewdelete()
  35. {
  36.  
  37. $this->load->view('view_delete');
  38. }
  39.  
  40. public function show()
  41. {
  42. // $this->load->model('user_model');
  43. $data['results'] = $this->user_model->get_users();
  44.  
  45.  
  46. $this->load->view('user_view', $data);
  47.  
  48. // foreach ($result as $object)
  49. // {
  50. // echo $object->id . "</br>";
  51. // }
  52. }
  53.  
  54. // public function insert()
  55. // {
  56.  
  57. // $username = "Peter";
  58. // $password = "12345";
  59. // $this->user_model->create_users([
  60. // 'username' => $username,
  61. // 'password' => $password
  62. // ]);
  63. // }
  64.  
  65. public function insert()
  66. {
  67. // echo $this->input->post('password') . "</br>";
  68. // echo $_POST['username'];
  69.  
  70.  
  71. //echo $email = $this->input->post('email');
  72. //echo $_SESSION["email"];
  73. // $email = $this->input->post('email');
  74.  
  75.  
  76. // $_SESSION["email"] = $email;
  77. // $_SESSION["pass"] = $pass;
  78. // $_SESSION["cpass"] = $cpass;
  79. // $_SESSION["fname"] = $fname;
  80. // $_SESSION["lname"] = $lname;
  81. // $_SESSION["phone"] = $phone;
  82. // $_SESSION["address"] = $address;
  83. $this->load->library('form_validation');
  84. $this->form_validation->set_rules('email', 'email', 'trim|required|valid_email|xss_clean');
  85. $this->form_validation->set_rules('fname', 'firstname', 'trim|alpha|required|xss_clean');
  86. $this->form_validation->set_rules('lname', 'lastname', 'trim|alpha|required|xss_clean');
  87. $this->form_validation->set_rules('phone', 'phone', 'trim|numeric|required|integer|exact_length[10]');
  88. $this->form_validation->set_rules('address', 'address', 'trim|alpha_dash|required');
  89. $this->form_validation->set_rules('pass', 'cpass', 'trim|required|matches[cpass]|md5');
  90. $this->form_validation->set_rules('pass', 'cpass', 'trim|required');
  91.  
  92. if ($this->form_validation->run() == FALSE)
  93. {
  94. $this->load->view('createfinal');
  95. echo "Error";
  96. }
  97.  
  98. else
  99. {
  100. $data = array(
  101. 'email' => $_SESSION["email"],
  102. 'firstname' => $_SESSION["fname"],
  103. 'lastname' => $_SESSION["lname"],
  104. 'phone' => $_SESSION["phone"],
  105. 'address' => $_SESSION["address"],
  106. 'twitter' => $this->input->post('twitter'),
  107. 'facebook' => $this->input->post('facebook'),
  108. 'googleplus' => $this->input->post('gplus'),
  109. 'password' => $_SESSION["pass"],
  110. 'confirm' => $_SESSION["cpass"],
  111. );
  112.  
  113. // echo var_dump($data);
  114.  
  115.  
  116. $result = $this->user_model->create_users($data);
  117.  
  118. $this->load->view('createfinal');
  119.  
  120. echo "<h1>The data has been inserted</h1>";
  121. }
  122. }
  123.  
  124. public function update()
  125. {
  126.  
  127. if (isset($_POST['update']))
  128. {
  129.  
  130. $id = $this->input->post('id');
  131. $data = array(
  132. 'username' => $this->input->post('username'),
  133. 'password' => $this->input->post('password')
  134. );
  135.  
  136. $this->user_model->update_users($data, $id);
  137.  
  138. echo "<h1> Data is updated successfully:) </h1>";
  139. $this->load->view('view_update');
  140. }
  141. else
  142. {
  143.  
  144. echo "Oops! There is something wrong!";
  145. }
  146.  
  147. }
  148.  
  149. public function delete()
  150. {
  151.  
  152. if (isset($_POST['delete']))
  153. {
  154.  
  155. $id = $this->input->post('id');
  156. $this->user_model->delete_users($id);
  157.  
  158. echo "<h1>The data has been deleted.</h1>";
  159.  
  160. }
  161. else
  162. {
  163.  
  164. echo "<h3>No Such data exist!</h3>";
  165. }
  166.  
  167. }
  168. }
  169. ?>
  170.  
  171. and here is the view that i wanna load..
  172.  
  173. createfinal.php:
  174.  
  175.  
  176. <!DOCTYPE html>
  177. <html>
  178.  
  179. <head>
  180. <title>Login Form</title>
  181. <link rel="stylesheet" type="text/css" href="<?php echo base_url();?>css/style.css">
  182. </head>
  183. <body>
  184. <!-- multistep form -->
  185. <form id="msform" action="viewinsert2" method="post">
  186. <!-- progressbar -->
  187. <ul id="progressbar">
  188. <li class="active">Account Setup</li>
  189. <li>Social Profiles</li>
  190. <li>Personal Details</li>
  191. </ul>
  192. <!-- fieldsets -->
  193. <fieldset>
  194. <h2 class="fs-title">Create your account</h2>
  195. <h3 class="fs-subtitle">This is step 1</h3>
  196. <input type="text" name="email" placeholder="Email" />
  197. <input type="password" name="pass" placeholder="Password" />
  198. <input type="password" name="cpass" placeholder="Confirm Password" />
  199. <input type="submit" name="next" class="next action-button" value="Next" />
  200. </fieldset>
  201.  
  202.  
  203. </body>
  204. </html>
  205.  
  206. The css folder is parallel to the application folder. Please help Me!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement