Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <body>
- <?php include("header.php"); ?>
- <?php include_once("analyticstracking.php") ?>
- <div class="container-fluid hero1" style="margin-top:-20px";>
- <div class="hero-inner">
- <h2 class="white">My Profile</h2>
- </div>
- </div>
- <div class="container" style="margin-top: 25px;">
- <h1><b>ACCOUNT</b></h1>
- <h3 style="padding-bottom: 50px;"><?php
- date_default_timezone_set("Asia/Kuala_Lumpur");
- $hour=date("H");
- if ($hour <=6) {
- echo "Welcome, ";
- }else if ($hour<=12){
- echo "Good morning, ";
- }else if($hour <=18){
- echo "Good afternoon, ";
- }else if($hour >=18){
- echo "Good evening, ";
- }else{
- echo "Hello, ";
- }
- ?>
- <?php echo ucfirst($this->session->userdata('username')); ?></h3>
- <div class="row padd">
- <label class="label">Phone No.</label></br>
- <p class="friendly"><?php echo $userdata[0]['phone1']; ?></p><br>
- </div>
- <div class="row padd">
- <label class="label">Email</label><br>
- <p class="friendly"><?php echo $userdata[0]['email'];?></p><br>
- </div>
- <form action="<?php echo base_url(); ?>users/update/" method="post" enctype="multipart/form-data" data-toggle="validator">
- <div class="padd col-xs-12 col-md-3">
- <label class="label">My IC/Matric Card</label></br>
- <input name="image" placeholder="Upload" class="upload friendly" type="file" accept="image/*" capture="environment" required>
- </div>
- <div class="col-xs-12 col-md-9 padd" style="overflow:auto;">
- <div class="picture"><img id="blah" style="width: 100%; height: 100%"
- <?php
- if($userdata[0]['image'] == "")
- {
- echo "src='https://style.anu.edu.au/_anu/4/images/placeholders/person.png'";
- }else{
- echo "src='" . str_replace('/index.php/','/',base_url())."media/images/users/".$userdata[0]['image']."'";
- }
- ?> >
- </div>
- </div>
- <div class="row padd">
- <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>
- <input type="hidden" value="<?php echo $userdata[0]['id']; ?>" name="id" />
- <input type="hidden" value="<?php echo $userdata[0]['account_status']; ?>" name="id" />
- <input type="hidden" value="<?php echo $userdata[0]['image']; ?>" name="oldimage"/>
- </div>
- </form>
- </body>
- </div>
- <?php include 'footer.php' ?>
- <script type="text/javascript">
- $(document).on('change','.upload',function(){
- files = this.files;
- size = files[0].size;
- if( size > 2000000){
- alert('Please upload an image less than 2mb');
- return false;
- }
- readURL(this);
- return true;
- });
- </script>
- <script>
- function readURL(input) {
- if (input.files && input.files[0]) {
- var reader = new FileReader();
- reader.onload = function (e) {
- $('#blah')
- .attr('src', e.target.result)
- .width(300)
- .height(150);
- };
- reader.readAsDataURL(input.files[0]);
- }
- }
- </script>
- public function profile()
- {
- $data['userdata'] = $this->usermodel->get_user($this->session->userdata('id'));
- $this->load->view('edit-profile1',$data);
- }
- public function update()
- {
- $user = new Users_model();
- // $user->phone1 = $this->input->post('phone1');
- $user->account_status = 1;
- //session data
- $user->id = $this->session->userdata('id');
- $user->password = $this->session->userdata('password');
- $user->username = $this->session->userdata('username');
- $user->email = $this->session->userdata('email');
- $user->user_role = $this->session->userdata('user_role');
- $image_type=$_FILES['image']['type'];
- $image_type = str_replace("image/", ".", $image_type);
- $image_name=$user->id . $image_type;
- //id to be set
- $id = $user->id;
- $config['upload_path'] = 'media/images/users';
- $config['allowed_types'] = 'jpg|jpeg|png|gif';
- $config['overwrite'] = TRUE;
- $config['file_name'] = $image_name;
- $this->load->library('upload', $config);
- $this->upload->initialize($config);
- if (!$this->upload->do_upload('image')) {
- $this->upload->display_errors('<span>', '</span>');
- $data['error'] = $this->upload->display_errors();
- $user->image = $this->input->post('oldimage');
- } else {
- $file_data = $this->upload->data();
- $data['success'] = "Your file is uploaded";
- $this->usermodel->update_image($user->id, $image_name);
- $user->image = $image_name;
- }
- $res = $this->db->update('users', $user, array('id' => $id));
- $URL = base_url() . "users/profile/";
- redirect($URL, "refresh");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement