ok

Mini Shell

Direktori : /proc/self/root/home2/selectio/www/thedentalpark.com/admin/
Upload File :
Current File : //proc/self/root/home2/selectio/www/thedentalpark.com/admin/profile.php

<?php  include "header.php";


// error_log();
$id=$_SESSION['issac_college']['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['upload_form'])) {
	    $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['issac_college']['photo']!='') {
        		unlink('upload/'.$_SESSION['issac_college']['photo']);	
        	}
    
        	// updating the data
        	$final_name = 'user-'.$_SESSION['issac_college']['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['issac_college']['id']));
    
            $message = 'User Photo is updated successfully.';
        	
        }
}
    
    
if(isset($_POST['password_form'])) {
	    $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['issac_college']['password'] = $_POST['password'];
    	    $pass=$_SESSION['issac_college']['password'];
        	
        	// updating the database
    		$statement = $pdo->prepare("UPDATE tbl_user SET password=? WHERE id=?");
    		$statement->execute(array($pass,$_SESSION['issac_college']['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">Profile Photo</a></li>
						<li><a href="#tab_2" data-toggle="tab">Update Password</a></li>
					</ul>
					<div class="tab-content">
      
          				<div class="tab-pane active" id="tab_1">
							<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">Existing Photo</label>
							            <div class="col-sm-6" style="padding-top:6px;">
							                <img src="upload/<?=$data['photo']?>" name="old_photo" style="width:200px;height:100px;object-fit:contain">
							            </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="upload_form">Update Photo</button>
										</div>
									</div>
								</div>
							</div>
							</form>
          				</div>
          				
          				<div class="tab-pane" id="tab_2">
							<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="password_form">Update Password</button>
										</div>
									</div>
								</div>
							</div>
							</form>
          				</div>
          				
          			</div>
				</div>			

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

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

Zerion Mini Shell 1.0