ok
Direktori : /home2/selectio/www/salemgovtitialumni.in/dashboard/admin/ |
Current File : /home2/selectio/www/salemgovtitialumni.in/dashboard/admin/alumini-reports-edit.php |
<?php require_once('header.php'); ?> <?php $type = $_REQUEST['type']; if($type==1){ $title_name = "Achievements"; }else if($type==2){ $title_name = "Annual Statements"; }else if($type==3){ $title_name = "Trainee Corner"; }else if($type==4){ $title_name = "Work details"; }else if($type==5){ $title_name = "Auditor report"; }else{ $title_name = ""; } if(isset($_POST['form1'])) { $valid = 1; if(empty($_POST['name'])) { $valid = 0; $error_message .= 'name can not be empty<br>'; } $path = $_FILES['photo']['name']; $path_tmp = $_FILES['photo']['tmp_name']; if($path!='') { $ext = pathinfo( $path, PATHINFO_EXTENSION ); $file_name = basename( $path, '.' . $ext ); } if($valid == 1) { $name = $_POST['name']; $ids = $_REQUEST['id']; if($path == '') { $statement = $pdo->prepare("UPDATE tbl_trainee SET name=?,type=? WHERE id=?"); $statement->execute(array($name,$type,$ids)); } else { if(isset($_POST['current_photo']) && ($_POST['current_photo'] != '')){ unlink('../assets/uploads/report/'.$_POST['current_photo']); } $final_name = 'service-'.$_REQUEST['id'].'.'.$ext; move_uploaded_file( $path_tmp, '../assets/uploads/report/'.$final_name ); $image_path ='assets/uploads/important/'.$final_name; $statement = $pdo->prepare("UPDATE tbl_important_links SET image=? WHERE id=?"); $statement->execute(array($image_path,$_REQUEST['id'])); } $success_message = $title_name.' is updated successfully!'; } } ?> <?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 <?= $title_name ?></h1> </div> <div class="content-header-right"> <a href="alumini-reports-lists.php?code=<?=$type?>" 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); foreach ($result as $row) { $name = $row['acheiver_name']; $photo = $row['acheiver_file']; } ?> <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"> <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> <div class="col-sm-6"> <input type="text" autocomplete="off" class="form-control" name="name" value="<?=$name?>" required> </div> </div> <div class="form-group"> <label for="" class="col-sm-2 control-label">Upload New Document </label> <div class="col-sm-9" style="padding-top:5px"> <input type="file" name="photo" class=""> <input type="hidden" name="current_photo" value="<?= $photo ?>" > <a target="_blank" href="https://www.salemgovtitialumni.in/dashboard/<?=$photo?>" class="btn btn-primary btn-xs" style="margin-top:4%;" >View Old Document</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'); ?>