ok
Direktori : /home2/selectio/public_html/salemgovtitialumni.in/dashboard/admin/ |
Current File : /home2/selectio/public_html/salemgovtitialumni.in/dashboard/admin/important-link-edit.php |
<?php require_once('header.php'); ?> <?php if(isset($_POST['form1'])) { $valid = 1; if(empty($_POST['name'])) { $valid = 0; $error_message .= 'name can not be empty<br>'; } if(empty($_POST['type'])) { $valid = 0; $error_message .= 'Important Link 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']; $type = $_POST['type']; $ids = $_REQUEST['id']; if($path == '') { $statement = $pdo->prepare("UPDATE tbl_important_links SET name=?,type=? WHERE id=?"); $statement->execute(array($name,$type,$ids)); } else { if(isset($_POST['current_photo']) && ($_POST['current_photo'] != '')){ unlink('../assets/uploads/important/'.$_POST['current_photo']); } $final_name = 'service-'.$_REQUEST['id'].'.'.$ext; move_uploaded_file( $path_tmp, '../assets/uploads/important/'.$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 = 'Event 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_important_links 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 Important Link</h1> </div> <div class="content-header-right"> <a href="important-links.php" class="btn btn-primary btn-sm">View All</a> </div> </section> <?php $statement = $pdo->prepare("SELECT * FROM tbl_important_links WHERE id=?"); $statement->execute(array($_REQUEST['id'])); $result = $statement->fetchAll(PDO::FETCH_ASSOC); foreach ($result as $row) { $name = $row['name']; $photo = $row['image']; $type = $row['type']; } ?> <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">Important Link <span>*</span></label> <div class="col-sm-6"> <select name="type" id="type" class="form-select valid font-size12 select2" style="width: 100%;" required> <option value="1" <?php if($type==1){ echo 'selected'; } ?> >Upcoming Events </option> <option value="2" <?php if($type==2){ echo 'selected'; } ?> >Alumni Seminar </option> </select> </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'); ?>