관리-도구
편집 파일: add-contact.php
<!DOCTYPE html> <html lang="en" dir="ltr"> <head> <?php include('include/head_admin.php'); $image = ''; $address = ''; $email = ''; $phone = ''; $enquiry_now_link = ''; $pay_link = ''; $map = ''; $footer_about = ''; $facebook = ''; $instagram = ''; $twitter = ''; $linkedin = ''; $youtube = ''; if (isset($_GET['id']) && $_GET['id'] != '') { $id = get_safe_value($con, $_GET['id']); $res = mysqli_query($con, "SELECT * from `contact` where `id`='$id'"); $check = mysqli_num_rows($res); if ($check > 0) { $row = mysqli_fetch_assoc($res); $image = $row['image']; $address = $row['address']; $email = $row['email']; $phone = $row['phone']; $enquiry_now_link = $row['enquiry_now_link']; $pay_link = $row['pay_link']; $map = $row['map']; $footer_about = $row['footer_about']; $facebook = $row['facebook']; $instagram = $row['instagram']; $twitter = $row['twitter']; $linkedin = $row['linkedin']; $youtube = $row['youtube']; } else { header('location:contact.php'); die(); } } if (isset($_POST['submit_contact'])) { // prx($_POST); $address = get_safe_value($con, $_POST['address']); $email = get_safe_value($con, $_POST['email']); $phone = get_safe_value($con, $_POST['phone']); $enquiry_now_link = get_safe_value($con, $_POST['enquiry_now_link']); $pay_link = get_safe_value($con, $_POST['pay_link']); $map = get_safe_value($con, $_POST['map']); $footer_about = get_safe_value($con, $_POST['footer_about']); $facebook = get_safe_value($con, $_POST['facebook']); $instagram = get_safe_value($con, $_POST['instagram']); $twitter = get_safe_value($con, $_POST['twitter']); $linkedin = get_safe_value($con, $_POST['linkedin']); $youtube = get_safe_value($con, $_POST['youtube']); if (isset($_GET['id']) && $_GET['id'] == 0) { if ($_FILES['image']['type'] != 'image/png' && $_FILES['image']['type'] != 'image/jpg' && $_FILES['image']['type'] != 'image/jpeg' && $_FILES['image']['type'] != 'image/webp') { $msg = "Please select only png, jpg, webp and jpeg image format"; } } else { if ($_FILES['image']['type'] != '') { if ($_FILES['image']['type'] != 'image/png' && $_FILES['image']['type'] != 'image/jpg' && $_FILES['image']['type'] != 'image/jpeg' && $_FILES['image']['type'] != 'image/jpeg') { $msg = "Please select only png, jpg, webp and jpeg image format"; } } } $msg = ""; if ($msg == '') { if (isset($_GET['id']) && $_GET['id'] != '') { if ($_FILES['image']['name'] != '') { $image = $_FILES['image']['name']; move_uploaded_file($_FILES['image']['tmp_name'], "../media/contact/" . $image); mysqli_query($con, "UPDATE `contact` SET `image`='$image',`address`='$address',`email`='$email',`phone`='$phone',`enquiry_now_link`='$enquiry_now_link',`pay_link`='$pay_link',`map`='$map',`footer_about`='$footer_about',`facebook`='$facebook',`instagram`='$instagram',`twitter`='$twitter',`linkedin`='$linkedin',`youtube`='$youtube' WHERE `id`='$id'"); } else { $update_query = "UPDATE `contact` SET `image`='$image',`address`='$address',`email`='$email',`phone`='$phone',`enquiry_now_link`='$enquiry_now_link',`pay_link`='$pay_link',`map`='$map',`footer_about`='$footer_about',`facebook`='$facebook',`instagram`='$instagram',`twitter`='$twitter',`linkedin`='$linkedin',`youtube`='$youtube' WHERE `id`='$id'"; mysqli_query($con, $update_query); } } else { $image = rand(111111111, 999999999) . '_' . $_FILES['image']['name']; move_uploaded_file($_FILES['image']['tmp_name'], "../media/contact/" . $image); $insert_query = "INSERT INTO `contact`(`image`, `address`, `email`, `phone`, `enquiry_now_link`, `pay_link`, `map`, `footer_about`, `facebook`, `instagram`, `twitter`, `linkedin`, `youtube`) VALUES ('$image','$address','$email','$phone','$enquiry_now_link','$pay_link','$map','$footer_about','$facebook','$instagram','$twitter','$linkedin','$youtube')"; mysqli_query($con, $insert_query); print_r($insert_query); } header('location:contact.php'); die(); } } ?> </head> <body> <!-- tap on top start --> <div class="tap-top"> <span class="lnr lnr-chevron-up"></span> </div> <!-- tap on tap end --> <!-- page-wrapper start --> <div class="page-wrapper compact-wrapper" id="pageWrapper"> <!-- Page Header Start--> <?php include('include/header_admin.php'); ?> <!-- Page Header Ends--> <!-- Page Body start --> <div class="page-body-wrapper"> <!-- Page Sidebar Start--> <?php include('include/sidebar_admin.php'); ?> <!-- Page Sidebar Ends--> <div class="page-body"> <!-- New Product Add Start --> <div class="container-fluid"> <div class="row"> <div class="col-12"> <div class="row"> <div class="col-sm-8 m-auto"> <div class="card"> <div class="card-body"> <div class="card-header-2"> <h5>Contact Information</h5> </div> <form method="post" enctype="multipart/form-data"> <div class="theme-form theme-form-2 mega-form"> <div class="mb-4 row align-items-center"> <label class="col-sm-3 col-form-label form-label-title">Contact Image</label> <div class="form-group col-sm-9"> <input class="form-control" type="file" name="image" placeholder="Contact Image" value="<?php echo $image ?>" <?php echo $image ?> > <?php if ($image != '') { echo "<a target='_blank' href='" . "../media/contact/" . $image . "'><img width='150px' src='" . "../media/contact/" . $image . "'/></a>"; } ?> </div> </div> <div class="mb-4 row align-items-center"> <label class="col-sm-3 col-form-label form-label-title">Address</label> <div class="form-group col-sm-9"> <input class="form-control" type="text" name="address" placeholder="Address" value="<?php echo $address ?>" required> </div> </div> <div class="mb-4 row align-items-center"> <label class="col-sm-3 col-form-label form-label-title">Email</label> <div class="form-group col-sm-9"> <input class="form-control" type="text" name="email" placeholder="Email" value="<?php echo $email ?>" required> </div> </div> <div class="mb-4 row align-items-center"> <label class="col-sm-3 col-form-label form-label-title">Phone</label> <div class="form-group col-sm-9"> <input class="form-control" type="text" name="phone" placeholder="Phone" value="<?php echo $phone ?>" required> </div> </div> <div class="mb-4 row align-items-center"> <label class="col-sm-3 col-form-label form-label-title">Enquiry Now Link</label> <div class="form-group col-sm-9"> <input class="form-control" type="text" name="enquiry_now_link" placeholder="Enquiry Now Link" value="<?php echo $enquiry_now_link ?>" required> </div> </div> <div class="mb-4 row align-items-center"> <label class="col-sm-3 col-form-label form-label-title">Pay Link</label> <div class="form-group col-sm-9"> <input class="form-control" type="text" name="pay_link" placeholder="Pay Link" value="<?php echo $pay_link ?>" required> </div> </div> <div class="mb-4 row align-items-center"> <label class="col-sm-3 col-form-label form-label-title">Map</label> <div class="form-group col-sm-9"> <input class="form-control" type="text" name="map" placeholder="Map" value="<?php echo $map ?>" required> </div> </div> <div class="mb-4 row align-items-center"> <label class="col-sm-3 col-form-label form-label-title">Footer About</label> <div class="form-group col-sm-9"> <input class="form-control" type="text" name="footer_about" placeholder="Footer About" value="<?php echo $footer_about ?>" required> </div> </div> <div class="mb-4 row align-items-center"> <label class="col-sm-3 col-form-label form-label-title">Facebook</label> <div class="form-group col-sm-9"> <input class="form-control" type="text" name="facebook" placeholder="Facebook" value="<?php echo $facebook ?>" required> </div> </div> <div class="mb-4 row align-items-center"> <label class="col-sm-3 col-form-label form-label-title">Instagram</label> <div class="form-group col-sm-9"> <input class="form-control" type="text" name="instagram" placeholder="Instagram" value="<?php echo $instagram ?>" required> </div> </div> <div class="mb-4 row align-items-center"> <label class="col-sm-3 col-form-label form-label-title">Twitter</label> <div class="form-group col-sm-9"> <input class="form-control" type="text" name="twitter" placeholder="Twitter" value="<?php echo $twitter ?>" required> </div> </div> <div class="mb-4 row align-items-center"> <label class="col-sm-3 col-form-label form-label-title">Linkedin</label> <div class="form-group col-sm-9"> <input class="form-control" type="text" name="linkedin" placeholder="Linkedin" value="<?php echo $linkedin ?>" required> </div> </div> <div class="mb-4 row align-items-center"> <label class="col-sm-3 col-form-label form-label-title">Youtube</label> <div class="form-group col-sm-9"> <input class="form-control" type="text" name="youtube" placeholder="Youtube" value="<?php echo $youtube ?>" required> </div> </div> </div> <button class="btn btn-solid" name="submit_contact" type="submit">Submit</button> </form> </div> </div> </div> </div> </div> </div> </div> <!-- New Product Add End --> <!-- footer Start --> <?php include('include/footer_admin.php'); ?> <!-- footer En --> </div> <!-- Container-fluid End --> </div> <!-- Page Body End --> </div> <!-- page-wrapper End --> <?php include('include/foot_admin.php'); ?> </body> </html>