Viewing file: service_add.php (6.39 KB) -rwxr-xr-x Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<? include 'index_IncludeAdmin.php'; $_SESSION['page'] = 'service.php';
if ($_POST['service_Add']) { $Jpg = strrchr($_FILES["service_photo"]["name"],"."); $service_photo = rand().rand().$Jpg; if(move_uploaded_file($_FILES["service_photo"]["tmp_name"],"../Files/service_photo/".$service_photo)){
$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().$service_name); $service_Add = "INSERT INTO `service` (`service_page`,`service_name`, `service_detail`, `service_photo`,`service_review`,`service_datetime`,`service_date`,`service_time`) VALUES('$service_page','$service_name','$service_detail','$service_photo','$service_review',now(),now(),now())"; $service_Reult = mysqli_query($con,$service_Add); $_SESSION[service_id] = mysqli_insert_id($con); if (!$service_Reult) { echo"<script>alert('เกิดข้อผิดพลาด หรือ ลิ้งเพจซ้ำ'); window.history.back(); </script>"; } if ($service_Reult) { if(isset($_FILES['service_picture_photo']['name'])&&$_FILES['service_picture_photo']['name']!=''){ $Count = count($_FILES['service_picture_photo']['name']); for ($i=0; $i < $Count; $i++) { $Jpg = strrchr($_FILES["service_picture_photo"]["name"][$i],"."); $service_picture_photo = rand().rand().$Jpg; if(move_uploaded_file($_FILES["service_picture_photo"]["tmp_name"][$i],"../Files/service_picture_photo/".$service_picture_photo)){ $service_picture_Add = "INSERT INTO `service_picture` (`service_id`,`service_picture_photo`) VALUES ('$_SESSION[service_id]','$service_picture_photo')"; $service_picture_Reult = mysqli_query($con,$service_picture_Add); if (!$service_picture_Reult) { echo"<script>alert('Error service_picture'); window.history.back(); </script>"; } } } }
echo"<script> window.location='service_one.php?INSERT'; </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> เพิ่ม บริการ </h3> <hr> </div> </div> <div class="row"> <div class="col-md-12 br-margin2"> <a href="service.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" 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 ตัวอักษร"></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"> <label class="control-label col-md-3" > รูป บริการ <span class="text-red"> * </span> </label> <div class="col-md-6"> <input Type="file" class="form-control" name="service_photo" required> </div> </div> <div class="form-group"> <label class="control-label col-md-3" > รูปภาพเพิ่มเติม </label> <div class="col-md-6"> <input type="file" class="form-control" multiple="multiple" name="service_picture_photo[]"> </div> <label class="control-label col-md-3 text-left" > สามารถเพิ่มได้ภายหลัง </label> </div> <div class="form-group"> <div class="col-md-offset-3 col-md-6"> <button Type="submit" class="btn btn-success"> <span class="glyphicon glyphicon-plus-sign"></span> ยืนยันการเพิ่ม </button> <input Type="hidden" name="service_Add" 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">
</textarea> </div> </div> </form> </div> <!-- 12 --> </div> <!-- row --> </div> <!-- 10 --> </div> <!-- row --> </div> <!-- container --> </body> </html>
|