Mini Shell
<?php
require_once("../config.php");
require_once("function-file.php");
require_once("function-menu.php");
cookiecheck();
$ben_id=$_GET['ben_id'];
$datas=$conn->prepare("select * from benifits where ben_id='$ben_id'");
$datas->execute();$result=$datas->fetch();
if(isset($_POST['save'])){
if(!empty($_FILES['ben_img']['name'])){
//Upload Image
$name=$_FILES['ben_img']['name'];
$ben_img=str_replace(" ","_",$name);
$tmp_name=$_FILES['ben_img']['tmp_name'];
$target_path="img/benifits/";
$target_path=$target_path.basename($ben_img);
move_uploaded_file($_FILES['ben_img']['tmp_name'],$target_path);
//--
}
else{$ben_img=$result['ben_img'];}
$ben_name=$_POST['ben_name'];
$ben_msg=$_POST['ben_msg'];
$conn->exec("UPDATE benifits SET ben_name='$ben_name',ben_img='$ben_img',ben_msg='$ben_msg' where ben_id='$ben_id'");
header("location:benefits.php");
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Edit Benefits</title>
<!-- Tell the browser to be responsive to screen width -->
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<?php cssfile();?>
</head>
<body class="hold-transition skin-blue layout-top-nav">
<!-- Site wrapper -->
<div class="wrapper">
<?php headermenu();?>
<!-- =============================================== -->
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<!-- Main content -->
<section class="content">
<!-- Default box -->
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">Edit Benefits</h3>
<div class="box-tools pull-right">
<a href="benefits.php" class="btn btn-info btn-sm" ><i class="fa fa-angle-double-left"></i> Back</a>
</div>
</div>
<div class="box-body">
<form action="#" method="post" role="form" class="form-horizontal" enctype="multipart/form-data">
<div class="form-group">
<div class="col-sm-6"><label>Name</label><input name="ben_name" class="form-control" placeholder="Enter Course Name" value="<?php echo $result['ben_name']; ?>"></div>
<div class="col-sm-6"><label>Image:</label><br>
<input type="file" id="file" name="ben_img" type="file" class="form-control" accept="image/*" onchange="loadFile(event)"></div>
</div>
<div class="form-group">
<div class="col-sm-6"><label>Message</label>
<textarea name="ben_msg" class="form-control" placeholder="Type Blog Description" rows="10"><?php echo $result['ben_msg']; ?></textarea></div>
<div class="col-sm-6"><img src="img/benifits/<?php echo $result['ben_img'];?>" id="output" class="img-responsive img-thumbnail"/></div>
</div>
<div class="form-group">
<div class="col-sm-12" align="right">
<button type="reset" class="btn btn-default" rows="4">Reset</button>
<button type="submit" name="save" class="btn btn-success" >Save</button></div>
</div>
</div><!-- /.box-body -->
</div><!-- /.box -->
</section><!-- /.content -->
</div></div><!-- /.content-wrapper -->
<?php footer();?>
</div><!-- ./wrapper -->
<?php jsfile();ratenum();?>
<script>
var loadFile = function(event) {
var output = document.getElementById('output');
output.src = URL.createObjectURL(event.target.files[0]);
};
</script>
</body>
</html>
Zerion Mini Shell 1.0