change pass:suseendhiran

This commit is contained in:
suseendhiran17 2023-05-11 14:57:02 +05:30
parent 915afbe6de
commit 286cb386da
7 changed files with 153 additions and 42 deletions

View File

@ -56,11 +56,12 @@ $routes->match(['post'],'/user_edit','Admin_controller::user_edit');
$routes->match(['get','post'],'/user_add','Admin_controller::user_add');
$routes->match(['get'],'/admin_profile/(:any)','Admin_controller::admin_profile/$1');
$routes->match(['post'],'/admin_profile','Admin_controller::admin_profile');
$routes->match(['post'],'/profilepic','Admin_controller::profilepic_insert');
$routes->match(['post'],'/profilepic_insert','Admin_controller::profilepic_insert');
$routes->match(['get'],'/credits_pack_list','Admin_controller::credits_pack_list');
$routes->match(['get'],'/credits_pack_edit/(:any)','Admin_controller::credits_pack_edit/$1');
$routes->match(['post'],'/credits_pack_edit','Admin_controller::credits_pack_edit');
$routes->match(['get','post'],'/credits_pack_add','Admin_controller::credits_pack_add');
$routes->match(['get','post'],'/user_password_change','Admin_controller::user_password_change');
$routes->match(['get'],'/admin_home','Dashboard::admin_home');
$routes->match(['get'],'/member_home','Dashboard::member_home');

View File

@ -157,25 +157,30 @@ class Admin_controller extends BaseController
public function profilepic_insert()
{
if($this->request->getmethod() == 'post')
{
if(isset($_FILES["image_file"]["name"]))
$path = ROOTPATH ."/public/assets/images/users";
if($this->request->getFile('profile'))
{
$config['upload_path'] = base_url()."/public/assets/images/users";
$config['allowed_types'] = 'jpg|jpeg|png|gif';
print_r($config);die();
$this->load->library('upload', $config);
if(!$this->upload->do_upload('image_file'))
{
echo $this->upload->display_errors();
}
else
{
$data = $this->upload->data();
echo '<img src="'.base_url().'upload/'.$data["file_name"].'" width="300" height="225" class="img-thumbnail" />';
}
$img = $this->request->getFile('profile');
if ($img->isValid() && ! $img->hasMoved())
{
//$newName = $img->getRandomName();
$f_type=$_FILES['profile']['name'];
$data['profile'] = $f_type;
$this->UserModel->where('id', $this->request->getVar('id') )->set($data)->update();
$img->move($path, $f_type);
return redirect()->to(base_url()."admin_profile/".md5($this->request->getVar('id')));
}
else
{
return redirect()->to(base_url()."admin_profile/".md5($this->request->getVar('id')));
}
}
else
{
return redirect()->to(base_url()."admin_profile/".md5($this->request->getVar('id')));
}
}
@ -238,6 +243,35 @@ class Admin_controller extends BaseController
echo view('credits_pack_form');
echo view('layout/footer');
}
public function user_password_change()
{
if($this->request->getmethod() == 'post')
{
//insert member details
$UserData = $this->request->getVar();
$old_password = $this->request->getVar('old_password');
$data = $this->UserModel->where('id', $this->request->getVar('id') )->find();
if (password_verify($old_password ,$data[0]['password']))
{
$this->UserModel->where('id', $this->request->getVar('id') )->set($UserData)->update();
$this->session->setTempdata('mail_success',"Password changed successfully",3);
return redirect()->to(base_url()."admin");
}
else
{
$this->session->setTempdata('error',"Entered wrong old password",3);
return redirect()->to(base_url()."user_password_change");
}
}
$userdata['userdata']=$this->dModel->getLoggedInUserData(session()->get('logged_user'));
echo view('layout/header',$userdata);
echo view('users_password');
echo view('layout/footer');
}
// -----------------------------------------------
}

View File

@ -45,7 +45,11 @@
<form method="post" action="<?= base_url()."admin"; ?>">
<?php if(session()->getTempdata('mail_success')):?>
<div class="alert alert-success" >
<?= session()->getTempdata('mail_success'); ?>
</div>
<?php endif;?>
<?php if(session()->getTempdata('error')):?>
<div class="alert alert-danger" >
<?= session()->getTempdata('error'); ?>

View File

@ -304,8 +304,8 @@ $(document).ready(function(){
</a>
<!-- item-->
<a href="<?= base_url()."admin_profile/". md5($userdata->id); ?>" class="dropdown-item notify-item">
<i class="ri-account-circle-line"></i>
<a href="<?= base_url()."user_password_change/" ?>" class="dropdown-item notify-item">
<i class="mdi mdi-lock-outline"></i>
<span>Change Password</span>
</a>

View File

@ -73,9 +73,10 @@ body {
<div class="col-lg-12 col-xl-12">
<div class="card text-center">
<div class="card-body">
<form id="form" data-parsley-validate class="form-horizontal form-label-left" method="post" action="" enctype="multipart/form-data">
<form id="form" data-parsley-validate class="form-horizontal form-label-left" method="post" action="<?= base_url()."profilepic_insert"; ?>" enctype="multipart/form-data">
<input id="id" name="id" value="<?= $userList[0]['id'] ?>" type="hidden" />
<?php if ($userList[0]['profile'] == NULL) { ?>
<button type="submit" class="btn btn-success" hidden>Update</button>
<?php if ($userList[0]['profile'] == '') { ?>
<div class="profilepic">
<!-- <img style="width: 100%;height: 100%; display: block;" src="<?php echo base_url(); ?>/assets/uploads/profile_picture/profile.jpg" alt="Avatar" title="Change the avatar"> -->
<img src='<?php echo base_url()."/public/assets/images/users/avatar-1.jpg" ?>' class="rounded-circle avatar-xl img-thumbnail" alt="profile-image">
@ -89,7 +90,7 @@ body {
else { ?>
<div class="profilepic">
<!-- <img style="width: 100%;height: 100%; display: block;" src="<?php echo base_url(); ?>/assets/uploads/profile_picture/profile.jpg" alt="Avatar" title="Change the avatar"> -->
<img src='<?php echo base_url()?>"/public/assets/images/users/<?php echo $userList[0]['profile'] ?>' class="rounded-circle avatar-xl img-thumbnail" alt="profile-image">
<img src='<?php echo base_url()."/public/assets/images/users/"?><?php echo $userList[0]['profile'] ?>' class="rounded-circle avatar-xl img-thumbnail" alt="profile-image">
<input id="file_profile" name="profile" class="typeFile1" type="file" hidden/>
<div class="profilepic__content">
<span class="profilepic__icon"><i class="fa fa-camera" style="font-size:25px;color:black"></i></span>
@ -137,27 +138,25 @@ $(".profilepic").one('click',function() {
});
// change login person profile pic => file name : user/profile.php
$(document).ready(function(){
$("#file_profile").change(function(){
$(".btn-success").click();
});
});
$(document).on('change','#file_profile',function(e){
var data = $("#form").serialize();
$.ajax({
type: "post",
url: "<?php echo base_url();?>profilepic",
data: data,
json: true,
success: function(response) {
alert(response)
if (response == true) {
alert("dakug");
}
// $(document).on('change','#file_profile',function(e){
// var data = $("#form").serialize();
// $.ajax({
// type: "post",
// url: "<?php echo base_url();?>profilepic_insert",
// data: data,
// json: true,
// success: function(response) {
// alert(response)
// if (response == true) {
// alert("dakug");
// }
},
error: function(jqXHR, textStatus, err) { alert('text status '+textStatus+', err '+err) }
});
});
// },
// error: function(jqXHR, textStatus, err) { alert('text status '+textStatus+', err '+err) }
// });
// });
</script>

View File

@ -148,7 +148,7 @@
<?php if(isset($userList)){ ?> Update <?php } else { ?> Save <?php } ?>
</button>
<button type="reset"
class="btn btn-secondary waves-effect">
class="btn btn-secondary waves-effect" onclick="history.back()">
Cancel
</button>
</div>

View File

@ -0,0 +1,73 @@
<div class="account-pages mt-5 mb-5">
<div class="container">
<div class="row justify-content-center">
<div class="col-lg-6">
<div class="card">
<div class="card-body">
<h3 class="header-title" style="text-align: center;">Change Password</h3>
<p class="sub-header">
</p>
<form method="post" action="<?= base_url()."user_password_change"; ?>" role="form" class="parsley-examples">
<input id="id" type="hidden" value="<?= $userdata->id; ?>" name="id">
<?php if(session()->getTempdata('mail_success')):?>
<div class="alert alert-success" >
<?= session()->getTempdata('mail_success'); ?>
</div>
<?php endif;?>
<?php if(session()->getTempdata('error')):?>
<div class="alert alert-danger" >
<?= session()->getTempdata('error'); ?>
</div>
<?php endif;?>
<div class="form-group row">
<label for="hori-pass1" class="col-4 col-form-label">Old Password<span class="text-danger">*</span></label>
<div class="col-7">
<input id="hori-pass" type="password" placeholder="Password" required
class="form-control" name="old_password">
</div>
</div>
<div class="form-group row">
<label for="hori-pass1" class="col-4 col-form-label">Password<span class="text-danger">*</span></label>
<div class="col-7">
<input id="hori-pass1" type="password" placeholder="Password" required
class="form-control" name="password">
</div>
</div>
<div class="form-group row">
<label for="hori-pass2" class="col-4 col-form-label">Confirm Password
<span class="text-danger">*</span></label>
<div class="col-7">
<input data-parsley-equalto="#hori-pass1" type="password" required
placeholder="Password" class="form-control" id="hori-pass2">
</div>
</div>
<div class="form-group row">
<div class="col-8 offset-4">
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1">
Submit
</button>
<button type="reset"
class="btn btn-secondary waves-effect">
Cancel
</button>
</div>
</div>
</form>
</div>
</div> <!-- end card-box -->
</div> <!-- end col -->
</div>
<!-- end row -->
</div>
<!-- end container -->
</div>