ok

Mini Shell

Direktori : /proc/thread-self/root/home2/selectio/www/salemgovtitialumni.in/dashboard/admin/
Upload File :
Current File : //proc/thread-self/root/home2/selectio/www/salemgovtitialumni.in/dashboard/admin/trainee-edit.php

<?php require_once('header.php'); ?>

<?php
if(isset($_POST['form1'])) {
    
    $date = date('Y-m-d');
    
  if($_FILES['pdf']["name"]!=""){
      
                    unlink('../'.$_POST['old_pdf']);
      
                    $file_name = $_FILES['pdf']['name'];
                    $tmp = explode('.', $file_name);
                    $extension = end($tmp);
                    //$extension = end(explode(".", $_FILES["image"]["name"]));
                    $image1 = rand(10,1000000000)."-".$date."-pdf." . $extension;
                    $upload = move_uploaded_file($_FILES['pdf']['tmp_name'], '../assets/uploads/report/' . $image1);
                    $pdf = 'assets/uploads/report/' .$image1;
            }else{
                $pdf=$_POST['old_pdf'];
            }
            
            move_uploaded_file( $path_tmp, '../assets/uploads/report/'.$final_name );

	
			$statement = $pdo->prepare("UPDATE tbl_trainee SET acheiver_name=?, acheiver_file=? WHERE id=?");
    		$statement->execute(array($_POST['name'],$pdf,$_REQUEST['id']));
	
	if($statement){

	    $success_message = 'Report is updated successfully!';
	}else{
	    $success_message = 'Somethig went wrong';
	}
}
?>

<?php
if(!isset($_REQUEST['id'])) {
	header('location: logout.php');
	exit;
} else {
	// Check the id is valid or not
	$statement = $pdo->prepare("SELECT * FROM tbl_trainee WHERE id=?");
	$statement->execute(array($_REQUEST['id']));
	$total = $statement->rowCount();
	$result = $statement->fetchAll(PDO::FETCH_ASSOC);
	if( $total == 0 ) {
		header('location: logout.php');
		exit;
	}
}
?>

<section class="content-header">
	<div class="content-header-left">
		<h1>Edit Service</h1>
	</div>
	<div class="content-header-right">
		<a href="trainee.php" class="btn btn-primary btn-sm">View All</a>
	</div>
</section>

<?php
$statement = $pdo->prepare("SELECT * FROM tbl_trainee WHERE id=?");
$statement->execute(array($_REQUEST['id']));
$result = $statement->fetchAll(PDO::FETCH_ASSOC);
?>

<section class="content">

	<div class="row">
		<div class="col-md-12">

			<?php if($error_message): ?>
			<div class="callout callout-danger">
				<p>
				<?php echo $error_message; ?>
				</p>
			</div>
			<?php endif; ?>

			<?php if($success_message): ?>
			<div class="callout callout-success">
				<p><?php echo $success_message; ?></p>
			</div>
			<?php endif; ?>

			<form class="form-horizontal" action="" method="post" enctype="multipart/form-data">
				<input type="hidden" name="current_photo" value="<?php echo $photo; ?>">
				<div class="box box-info">
					<div class="box-body">
						<div class="form-group">
							<label for="" class="col-sm-2 control-label">Report Name <span>*</span></label>
							<div class="col-sm-6">
								<input type="text" autocomplete="off" class="form-control" name="name" value="<?=$result[0]['acheiver_name'] ?>">
							</div>
						</div>
						
						<div class="form-group">
							<label for="" class="col-sm-2 control-label">Photo </label>
							<div class="col-sm-6" style="padding-top:5px">
								<input type="file" name="pdf">(Only jpg, jpeg, gif and png are allowed)
							</div>
						</div>	
						
					
						<div class="form-group">
							<label for="" class="col-sm-2 control-label">Existing pdf</label>
							<div class="col-sm-9" style="padding-top:5px">
							    <input type="hidden" autocomplete="off" class="form-control" name="old_pdf" value="<?=$result[0]['acheiver_file'] ?>">
								<a target="_blank" href="../<?=$result[0]['acheiver_file'] ?>" alt="Report" style="width:180px;"> PDF </a>
							</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">Submit</button>
							</div>
						</div>
					</div>
				</div>
			</form>
		</div>
	</div>

</section>

<?php require_once('footer.php'); ?>

Zerion Mini Shell 1.0