ok

Mini Shell

Direktori : /proc/thread-self/root/proc/thread-self/root/home2/selectio/www/saew.in/admin/
Upload File :
Current File : //proc/thread-self/root/proc/thread-self/root/home2/selectio/www/saew.in/admin/profile-edit.php

<?php  include "header.php";
if(isset($_POST['form1'])) {

	if($_SESSION['hrm']['id'] == '1' ) {

		$valid = 1;
$error_message="";
	    if(empty($_POST['full_name'])) {
	        $valid = 0;
	        $error_message .= "Name can not be empty<br>";
	    }

	    if(empty($_POST['email'])) {
	        $valid = 0;
	        $error_message .= 'Email address can not be empty<br>';
	    } else {
	    	if (filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) === false) {
		        $valid = 0;
		        $error_message .= 'Email address must be valid<br>';
		    } else {
		    	// current email address that is in the database
		    	$statement = $pdo->prepare("SELECT * FROM tbl_employee WHERE id=?");
				$statement->execute(array($_SESSION['hrm']['id']));
				$result = $statement->fetchAll(PDO::FETCH_ASSOC);
				foreach($result as $row) {
					$current_email = $row['email'];
				}

		    	$statement = $pdo->prepare("SELECT * FROM tbl_employee WHERE email=? and email!=?");
		    	$statement->execute(array($_POST['email'],$current_email));
		    	$total = $statement->rowCount();							
		    	if($total) {
		    		$valid = 0;
		        	$error_message .= 'Email address already exists<br>';
		    	}
		    }
	    }

	    if($valid == 1) {
			
			$_SESSION['hrm']['name'] = $_POST['full_name'];
	    	$_SESSION['hrm']['email'] = $_POST['email'];

			// updating the database
			$statement = $pdo->prepare("UPDATE tbl_employee SET name=?, email=?, mobile=? WHERE id=?");
			$statement->execute(array($_POST['full_name'],$_POST['email'],$_POST['phone'],$_SESSION['hrm']['id']));

	    	$success_message = 'User Information is updated successfully.';
	    }
	}
	else {
		$_SESSION['hrm']['mobile'] = $_POST['phone'];

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

		$success_message = 'User Information is updated successfully.';	
	}
}

if(isset($_POST['form2'])) {

  
  

    if(isset($_FILES['photo']) && $_FILES["photo"]["name"]!=""){
                        $extension = end(explode(".", $_FILES["photo"]["name"]));
                        $image = rand(10,1000000000)."-".$date."-image." . $extension;
                        $upload = move_uploaded_file($_FILES['photo']['tmp_name'], 'upload/' . $image);
                        $upload_image = 'upload/' . $image;   
                }
                else{
                    $upload_image=$_POST['old_photo'];
                }
    

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

        $success_message = 'User Photo is updated successfully.';
    	
   
}


if(isset($_POST['form3'])) {
	$valid = 1;

	if( empty($_POST['password'])) {
        $valid = 0;
        $error_message .= "Password can not be empty<br>";
    }

    

    if($valid == 1) {

    	$pass="";
    	if($_SESSION['hrm']['id'] == '1')
    	{
    	    $_SESSION['hrm']['password'] = ($_POST['password']);
    	    $pass=$_SESSION['hrm']['password'];
    	}
    	else
    	{
    	    $_SESSION['hrm']['password'] = $_POST['password'];
    	    $pass=$_SESSION['hrm']['password'];
    	}

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

    	$success_message = 'User Password is updated successfully.';
    }
}

    
?>

<?php
$statement = $pdo->prepare("SELECT * FROM tbl_employee WHERE id=?");
$statement->execute(array($_SESSION['hrm']['id']));
$statement->rowCount();
$result = $statement->fetchAll(PDO::FETCH_ASSOC);							
foreach ($result as $row) {
	$name =   $row['name'];
	$email     = $row['email'];
	$mobile     = $row['mobile'];
	$photo     = $row['photo'];
}

?>

<style>
    .input-group-addon, .input-group-btn{
            width: 45%;
    }
</style>

<div class="content-wrapper" style="background:white;">
        <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)  { ?>
            <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; ?>
            </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>







<section class="content">
    
    <div class="row">
        <div class="col-md-12">
            <h3>EDIT PROFILE</h3>
            
        </div>
    </div>
    
    
    <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">Update Information</a></li>
						<li><a href="#tab_2" data-toggle="tab">Update 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">
							
							<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">Name <span>*</span></label>
											<?php
										if($_SESSION['hrm']['id'] == '1') {
											?>
												<div class="col-sm-4">
													<input type="text" class="form-control" name="full_name" value="<?php echo $name; ?>">
												</div>
											<?php
										} else {
											?>
												<div class="col-sm-4" style="padding-top:7px;">
													<?php echo $name; ?>
												</div>
											<?php
										}
										?>
										
									</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="<?php echo $photo; ?>" class="existing-photo" width="140">
							            </div>
							        </div>
									
									<div class="form-group">
										<label for="" class="col-sm-2 control-label">Email Address <span>*</span></label>
										<?php
										if($_SESSION['hrm']['id'] == '1') {
											?>
												<div class="col-sm-4">
													<input type="email" class="form-control" name="email" value="<?php echo $email; ?>">
												</div>
											<?php
										} else {
											?>
											<div class="col-sm-4" style="padding-top:7px;">
												<?php echo $email; ?>
											</div>
											<?php
										}
										?>
										
									</div>
									<div class="form-group">
										<label for="" class="col-sm-2 control-label">Phone </label>
										<div class="col-sm-4">
											<input type="text" class="form-control" name="phone" value="<?php echo $mobile; ?>">
										</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="form1">Update Information</button>
										</div>
									</div>
								</div>
							</div>
							</form>
          				</div>
          				<div class="tab-pane" id="tab_2">
							<form class="form-horizontal" action="" method="post" enctype="multipart/form-data">
							<div class="box box-info">
								<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;">
							                
							                 <?php if($_SESSION['hrm']['photo']==''){ ?>   
                                        <img src="upload/default-photo.png" class="img-thumbnail" alt="" style="width:140px;height:180px;">
                                                
                                                <?php }else{ ?>
                                        <img src="<?=$_SESSION['hrm']['photo']?>" class="img-thumbnail" alt="" style="width:140px;height:180px;"> <?php } ?>
                                            <input type="file" name="photo"  placeholder="Photo" class="form-control tip" id="photo"  />
                                            <input type="hidden" name="old_photo"  value="<?=$_SESSION['hrm']['photo']?>" class="form-control tip" id="old_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"></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 include "footer.php";?>

Zerion Mini Shell 1.0