Advertisement
Guest User

Untitled

a guest
Sep 14th, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.45 KB | None | 0 0
  1. <body>
  2. <?php include("header.php"); ?>
  3. <?php include_once("analyticstracking.php") ?>
  4. <div class="container-fluid hero1" style="margin-top:-20px";>
  5. <div class="hero-inner">
  6. <h2 class="white">My Profile</h2>
  7. </div>
  8. </div>
  9.  
  10. <div class="container" style="margin-top: 25px;">
  11. <h1><b>ACCOUNT</b></h1>
  12.  
  13. <h3 style="padding-bottom: 50px;"><?php
  14. date_default_timezone_set("Asia/Kuala_Lumpur");
  15. $hour=date("H");
  16.  
  17. if ($hour <=6) {
  18. echo "Welcome, ";
  19. }else if ($hour<=12){
  20. echo "Good morning, ";
  21. }else if($hour <=18){
  22. echo "Good afternoon, ";
  23. }else if($hour >=18){
  24. echo "Good evening, ";
  25. }else{
  26. echo "Hello, ";
  27. }
  28. ?>
  29.  
  30. <?php echo ucfirst($this->session->userdata('username')); ?></h3>
  31.  
  32. <div class="row padd">
  33. <label class="label">Phone No.</label></br>
  34. <p class="friendly"><?php echo $userdata[0]['phone1']; ?></p><br>
  35. </div>
  36.  
  37. <div class="row padd">
  38. <label class="label">Email</label><br>
  39.  
  40. <p class="friendly"><?php echo $userdata[0]['email'];?></p><br>
  41. </div>
  42.  
  43. <form action="<?php echo base_url(); ?>users/update/" method="post" enctype="multipart/form-data" data-toggle="validator">
  44.  
  45. <div class="padd col-xs-12 col-md-3">
  46.  
  47. <label class="label">My IC/Matric Card</label></br>
  48.  
  49. <input name="image" placeholder="Upload" class="upload friendly" type="file" accept="image/*" capture="environment" required>
  50. </div>
  51.  
  52. <div class="col-xs-12 col-md-9 padd" style="overflow:auto;">
  53.  
  54. <div class="picture"><img id="blah" style="width: 100%; height: 100%"
  55. <?php
  56.  
  57. if($userdata[0]['image'] == "")
  58.  
  59. {
  60.  
  61. echo "src='https://style.anu.edu.au/_anu/4/images/placeholders/person.png'";
  62.  
  63. }else{
  64.  
  65. echo "src='" . str_replace('/index.php/','/',base_url())."media/images/users/".$userdata[0]['image']."'";
  66.  
  67. }
  68.  
  69. ?> >
  70. </div>
  71. </div>
  72.  
  73. <div class="row padd">
  74.  
  75. <button type="submit" style='width: 100%; margin-top:20px; margin-bottom: 20px !important; background-color: #59d389; color: white;' class="btn btn-responsive btn-md center-block">Save Changes</button>
  76.  
  77. <input type="hidden" value="<?php echo $userdata[0]['id']; ?>" name="id" />
  78.  
  79. <input type="hidden" value="<?php echo $userdata[0]['account_status']; ?>" name="id" />
  80.  
  81. <input type="hidden" value="<?php echo $userdata[0]['image']; ?>" name="oldimage"/>
  82.  
  83. </div>
  84.  
  85. </form>
  86. </body>
  87.  
  88. </div>
  89.  
  90. <?php include 'footer.php' ?>
  91.  
  92. <script type="text/javascript">
  93.  
  94. $(document).on('change','.upload',function(){
  95.  
  96. files = this.files;
  97.  
  98. size = files[0].size;
  99.  
  100. if( size > 2000000){
  101.  
  102. alert('Please upload an image less than 2mb');
  103.  
  104. return false;
  105.  
  106. }
  107.  
  108. readURL(this);
  109.  
  110. return true;
  111.  
  112. });
  113.  
  114. </script>
  115.  
  116. <script>
  117.  
  118. function readURL(input) {
  119.  
  120. if (input.files && input.files[0]) {
  121.  
  122. var reader = new FileReader();
  123.  
  124. reader.onload = function (e) {
  125.  
  126. $('#blah')
  127.  
  128. .attr('src', e.target.result)
  129.  
  130. .width(300)
  131.  
  132. .height(150);
  133.  
  134. };
  135.  
  136. reader.readAsDataURL(input.files[0]);
  137.  
  138. }
  139.  
  140. }
  141.  
  142. </script>
  143.  
  144. public function profile()
  145. {
  146. $data['userdata'] = $this->usermodel->get_user($this->session->userdata('id'));
  147. $this->load->view('edit-profile1',$data);
  148. }
  149.  
  150. public function update()
  151. {
  152. $user = new Users_model();
  153.  
  154. // $user->phone1 = $this->input->post('phone1');
  155. $user->account_status = 1;
  156.  
  157. //session data
  158. $user->id = $this->session->userdata('id');
  159. $user->password = $this->session->userdata('password');
  160. $user->username = $this->session->userdata('username');
  161. $user->email = $this->session->userdata('email');
  162. $user->user_role = $this->session->userdata('user_role');
  163. $image_type=$_FILES['image']['type'];
  164. $image_type = str_replace("image/", ".", $image_type);
  165. $image_name=$user->id . $image_type;
  166. //id to be set
  167. $id = $user->id;
  168.  
  169. $config['upload_path'] = 'media/images/users';
  170. $config['allowed_types'] = 'jpg|jpeg|png|gif';
  171. $config['overwrite'] = TRUE;
  172. $config['file_name'] = $image_name;
  173.  
  174. $this->load->library('upload', $config);
  175. $this->upload->initialize($config);
  176.  
  177. if (!$this->upload->do_upload('image')) {
  178. $this->upload->display_errors('<span>', '</span>');
  179. $data['error'] = $this->upload->display_errors();
  180. $user->image = $this->input->post('oldimage');
  181. } else {
  182. $file_data = $this->upload->data();
  183. $data['success'] = "Your file is uploaded";
  184. $this->usermodel->update_image($user->id, $image_name);
  185. $user->image = $image_name;
  186. }
  187.  
  188.  
  189. $res = $this->db->update('users', $user, array('id' => $id));
  190. $URL = base_url() . "users/profile/";
  191. redirect($URL, "refresh");
  192. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement