Viewing file: service_update.php (5.62 KB) -rwxr-xr-x Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<? include 'index_IncludeAdmin.php'; $_SESSION['page'] = 'service.php';
if (isset($_GET[service_id])){ $_SESSION[service_id] = $_GET[service_id]; } $service_id = $_SESSION[service_id] ;
$service_SL = " SELECT * FROM service WHERE service_id = '$service_id'"; $service_QR = mysqli_query($con,$service_SL); $service = mysqli_fetch_array($service_QR);
if ($_POST['serviceUpdate']) {
$service_name = htmlspecialchars($_POST['service_name'], ENT_QUOTES ); $service_detail = htmlspecialchars($_POST['service_detail'], ENT_QUOTES ); $service_review = function_review($_POST['service_review']); $service_page = function_page(random_string().$_POST['service_name']);
$service_Update = "UPDATE `service` SET `service_datetime` = NOW(), `service_page` = '$service_page', `service_name` = '$service_name', `service_detail` = '$service_detail', `service_review` = '$service_review' WHERE `service_id` = '$service_id'"; $service_Reult = mysqli_query($con,$service_Update);
if (!$service_Reult) { echo"<script>alert('เกิดข้อผิดพลาด'); window.history.back(); </script>"; }
if($_FILES['service_photo']['name']!=''){ @unlink("../Files/service_photo/".$service['service_photo']); $file = rand().$_FILES["service_photo"]["name"]; $upload = move_uploaded_file($_FILES["service_photo"]["tmp_name"],"../Files/service_photo/".$file); $service_photo_Update = "UPDATE `service` SET `service_photo` = '$file' WHERE `service_id` = '$service_id'"; $service_photo_Reult = mysqli_query($con,$service_photo_Update); }
if ($service_Reult) { echo"<script> window.location='service_one.php?UPDATE'; </script>"; } }
?>
<!DOCTYPE html> <html> <head> <? include 'index_Head.php'; ?> </head> <body> <? include 'index_Navbar.php'; ?> <div class="container-fluid"> <div class="row"> <div class="col-md-2" id="main-left"> <div class="row"> <div class="col-md-12"> <? include 'index_AdminMenu.php'; ?> </div> </div> </div> <div class="col-md-10"> <div class="row"> <div class="col-md-12"> <h3> แก้ไข บริการ : <span class="text-primary bold"> <?php echo $service[service_name]; ?> </span> </h3> <hr> </div> </div> <div class="row"> <div class="col-md-12 br-margin2"> <a href="service_one.php" class="btn btn-primary"><span class="glyphicon glyphicon-step-backward"></span> กลับ </a> </div> <div class="col-md-12"> <form class="form-horizontal" method="post" enctype="multipart/form-data"> <div class="panel panel-default"> <div class="panel-heading"> กรอกรายละเอียด "บริการ" ที่ต้องการแก้ไข </div> <div class="panel-body"> <div class="form-group"> <label class="control-label col-md-3" > ชื่อบริการ <span class="text-red"> * </span> </label> <div class="col-md-6"> <input id="service_name" type="text" class="form-control" value="<? echo $service[service_name]; ?>" name="service_name" required maxlength="80" placeholder="ความยาวไม่เกิน 80 ตัวอักษร" > </div> <label class="control-label col-md-3 text-left" > <span id="service_name_chars" class="text-muted"> </span> </label> <script type="text/javascript"> var service_name = 80; $('#service_name').keyup(function() { var length = $(this).val().length; var length = service_name-length; $('#service_name_chars').text(length); }); </script> </div> <div class="form-group"> <label class="control-label col-md-3" > รายละเอียดเบื้องต้น </label> <div class="col-md-6"> <textarea id="service_detail" class="form-control" rows="4" name="service_detail" maxlength="250" placeholder="รายละเอียดแนะนำ สั้นๆ ความยาวไม่เกิน 250 ตัวอักษร"><? echo $service[service_detail]; ?></textarea> </div> <label class="control-label col-md-2 text-left" > <span id="service_detail_chars" class="text-muted"> </span> </label> <script type="text/javascript"> var service_detail = 250; $('#service_detail').keyup(function() { var length = $(this).val().length; var length = service_detail-length; $('#service_detail_chars').text(length); }); </script> </div> <div class="form-group"> <div class="col-md-offset-3 col-md-6"> <button onclick="return confirm('ยืนยันการแก้ไข ? ')" type="submit" class="btn btn-info"> <span class="glyphicon glyphicon-floppy-disk"></span> บันทึกการแก้ไข </button> <input type="hidden" name="serviceUpdate" value="x"> </div> </div> </div> </div> <div class="panel panel-default"> <div class="panel-heading"> เนื้อหา </div> <div class="panel-body"> <textarea class="ckeditor" name="service_review"> <? echo $service[service_review]; ?> </textarea> </div> <div class="panel-footer"> แก้ไขล่าสุด : <?php echo $service[service_datetime]; ?> </div> </div> </form> </div> <!-- 12 --> </div> <!-- row --> </div> <!-- 10 --> </div> <!-- row --> </div> <!-- container --> </body> </html>
|