ok

Mini Shell

Direktori : /home2/selectio/public_html/tnpsctestbatch.com/admin/old/
Upload File :
Current File : /home2/selectio/public_html/tnpsctestbatch.com/admin/old/profile.php

<?php  include "header.php";
$id=$_SESSION['hrm']['id'];

    $statement = $pdo->prepare("SELECT * FROM tbl_user where id ='$id'");
    $statement->execute();
    $emp_data = $statement->fetchAll(PDO::FETCH_ASSOC);
    $totalData = $statement->rowCount();
    
    
    if(isset($_POST['form2'])) {
	    $valid = 1;
    	$path = $_FILES['photo']['name'];
        $path_tmp = $_FILES['photo']['tmp_name'];
        if($path!='') {
            $ext = pathinfo( $path, PATHINFO_EXTENSION );
            $file_name = basename( $path, '.' . $ext );
            if( $ext!='jpg' && $ext!='png' && $ext!='jpeg' && $ext!='gif' ) {
                $valid = 0;
                $error_message .= 'You must have to upload jpg, jpeg, gif or png file<br>';
            }
        }

    if($valid == 1) {

    	// removing the existing photo
    	if($_SESSION['hrm']['photo']!='') {
    		unlink('/upload/'.$_SESSION['hrm']['photo']);	
    	}

    	// updating the data
    	$final_name = 'upload/user-'.$_SESSION['hrm']['id'].'.'.$ext;
        move_uploaded_file( $path_tmp, 'upload/'.$final_name );
        $_SESSION['hrm']['photo'] = $final_name;

        // updating the database
		$statement = $pdo->prepare("UPDATE tbl_user SET photo=? WHERE id=?");
		$statement->execute(array($final_name,$_SESSION['hrm']['id']));

        $message = 'User Photo is updated successfully.';
    	
    }
}
    
    
    if(isset($_POST['form3'])) {
	    $valid = 1;
    	if( empty($_POST['password']) || empty($_POST['re_password']) ) {
            $valid = 0;
            $error_message .= "Password can not be empty<br>";
        }
        if( !empty($_POST['password']) && !empty($_POST['re_password']) ) {
        	if($_POST['password'] != $_POST['re_password']) {
    	    	$valid = 0;
    	        $error_message .= "Passwords do not match<br>";	
        	}        
        }
    if($valid == 1) {
    	$pass="";
    
    	    $_SESSION['hrm']['password'] = $_POST['password'];
    	    $pass=$_SESSION['hrm']['password'];
    	
    	// updating the database
		$statement = $pdo->prepare("UPDATE tbl_user SET password=? WHERE id=?");
		$statement->execute(array($pass,$_SESSION['hrm']['id']));
    	$message = 'User Password is updated successfully.';
    }
}

?>


<div class="content-wrapper" style="background:white;">
    <br>
        <div class="col-lg-12 alerts">
            <div id="custom-alerts" style="display:none;">
                <div class="alert alert-dismissable">
                    <div class="custom-msg"></div>
                </div>
            </div>
            <?php if ($error_message)  { ?>
            <div class="alert alert-danger alert-dismissable">
                <button aria-hidden="true" data-dismiss="alert" class="close" type="button">×</button>
                <h4><i class="icon fa fa-ban"></i> Error</h4>
                <?= $error_message; ?>
            </div>
            <?php $error=0;} if ($warning) { ?>
            <div class="alert alert-warning alert-dismissable">
                <button aria-hidden="true" data-dismiss="alert" class="close" type="button">×</button>
                <h4><i class="icon fa fa-warning"></i> warning</h4>
                <?= $warning; ?>
            </div>
            <?php  $warning=0;} if ($message) { ?>
            <div class="alert alert-success alert-dismissable">
                <button aria-hidden="true" data-dismiss="alert" class="close" type="button">×</button>
                <h4>    <i class="icon fa fa-check"></i> Success</h4>
                <?= $message; ?>
            </div>
            <?php $message=0; } ?>
        </div>
        <div class="clearfix"></div>





<?php foreach($emp_data as $data){ ?>

<section class="content">
    <div class="row">
		<div class="col-md-12">
				
				<div class="nav-tabs-custom">
					<ul class="nav nav-tabs">
						<li class="active"><a href="#tab_1" data-toggle="tab">Personal Infomation Details</a></li>
						<li><a href="#tab_2" data-toggle="tab">Profile Photo</a></li>
						<li><a href="#tab_3" data-toggle="tab">Update Password</a></li>
					</ul>
					<div class="tab-content">
          				<div class="tab-pane active" id="tab_1">
							 <div class="row">
		                      <div class="col-md-2">
		                          <center><h5 class="box-title"><b><i class="fa fa-user"></i> Profile </b></h5></center>
		                          <img src="<?=$data['photo']?>" style="width:150px;">
		                      </div>
		                      <div class="col-md-4">    
		                      <center><h5 class="box-title"><b><i class="fa fa-user"></i> Personal Info </b></h5></center>
                                    Name : <b><?=$data['emp_name']?></b><br>
                                    Father Name :<b><?=$data['fname']?></b><br>
                                    Date of Birth :<b><?=$data['dob']?></b><br>
                                    Gender :<b><?=$data['gender']?></b><br>
                                    Mobile No :<b><?=$data['emp_mobile']?></b><br>
		                      </div>
		                      <div class="col-md-3">
		                          <center><h5 class="box-title"><b><i class="fa fa-user"></i> Department </b></h5></center>
		                          Department  : <b> <?php
                                                  
                                                      $sql="SELECT p.*,(select departement from tbl_departement WHERE tbl_departement.id=p.department_id) as departement_name FROM tbl_user p where p.id=$id";
                                                        $statement = $pdo->prepare($sql);
                                                        $statement->execute();
                                                        $emp_data = $statement->fetchAll(PDO::FETCH_ASSOC);
                                                         ?>
                                                         <?php foreach($emp_data as $data){ ?>
                                                         <label class="lbl" for="permanentadress"><?=$data['departement_name']?></label>
                                                         <?php
                                                         }
                                                         ?></b><br>
		                          Designation : <b> <?php
                                                
                                                      $sql="SELECT p.*,(select desgination from tbl_desgination WHERE tbl_desgination.id=p.designation_id) as designation_name FROM tbl_user p where p.id=$id";
                                                        $statement = $pdo->prepare($sql);
                                                        $statement->execute();
                                                        $emp_data = $statement->fetchAll(PDO::FETCH_ASSOC);
                                                         ?>
                                                         <?php foreach($emp_data as $data){ ?>
                                                         <label class="lbl" for="permanentadress"><?=$data['designation_name']?></label>
                                                         <?php
                                                         }
                                                         ?></b><br>
		                          Date of Joining : <b><?=$data['joining_date']?></b><br>
		                      </div>
		                      <div class="col-md-3">
		                          <center><h5 class="box-title"><b><i class="fa fa-user"></i> Account Login Details </b></h5></center>
		                          User Type: <b>***</b><br>
		                          Role : <b>***</b><br>
		                          Email Id :<b><?=$data['email']?></b><br>
		                          Personal Email Id :<b><?=$data['personal_emai']?></b><br>
		                          Password :<b>*****</b><br>
		                      </div>
							</div>
							
							
							
							
							
							
          				</div>
          				<div class="tab-pane" id="tab_2">
							<form class="form-horizontal" action="" method="post" enctype="multipart/form-data">
							<div >
								<div class="box-body">
									<div class="form-group">
							            <label for="" class="col-sm-2 control-label">New Photo</label>
							            <div class="col-sm-6" style="padding-top:6px;">
							                <input type="file" name="photo">
							            </div>
							        </div>
							        <div class="form-group">
										<label for="" class="col-sm-2 control-label"></label>
										<div class="col-sm-6">
											<button type="submit" class="btn btn-success pull-left" name="form2">Update Photo</button>
										</div>
									</div>
								</div>
							</div>
							</form>
          				</div>
          				<div class="tab-pane" id="tab_3">
							<form class="form-horizontal" action="" method="post">
							<div class="box box-info">
								<div class="box-body">
									<div class="form-group">
										<label for="" class="col-sm-2 control-label">Password </label>
										<div class="col-sm-4">
											<input type="password" class="form-control" name="password">
										</div>
									</div>
									<div class="form-group">
										<label for="" class="col-sm-2 control-label">Retype Password </label>
										<div class="col-sm-4">
											<input type="password" class="form-control" name="re_password">
										</div>
									</div>
							        <div class="form-group">
										<label for="" class="col-sm-2 control-label"></label>
										<div class="col-sm-6">
											<button type="submit" class="btn btn-success pull-left" name="form3">Update Password</button>
										</div>
									</div>
								</div>
							</div>
							</form>

          				</div>
          			</div>
				</div>			

		</div>
	</div>
</section>
<?php } ?>

<?php include "footer.php";?>

Zerion Mini Shell 1.0