Viewing file: edit-testimonials.php (7.87 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
include 'conn.php';
require_once 'auth.php';
if (isset($_GET['edit']) && !empty($_GET['edit'])) {
$testimonial_id = $_GET['edit'];
$result = mysqli_query($con, "SELECT * FROM testimonials WHERE id = $testimonial_id");
$result1 = mysqli_fetch_array($result);
if (mysqli_num_rows($result) == 1) {
$testimonial = mysqli_fetch_assoc($result);
} else {
exit("Testimonial not found");
}
} else {
exit("No testimonial ID provided");
}
if (isset($_POST['update'])) {
$title = $_POST['title'];
$designation = $_POST['designation'];
$descrip = $_POST['comments'];
$descrip_fa = $_POST['comments_fa'];
$title_fa = $_POST['title_fa'];
$designation_fa = $_POST['designation_fa'];
if ($_FILES['lis_img']['name'] != '') {
if (!empty($result1['img'])) {
$old_lis_img_path = "images/testimonial/" . $result1['img'];
unlink($old_lis_img_path);
}
$lis_img = rand() . $_FILES['lis_img']['name'];
$tempname = $_FILES['lis_img']['tmp_name'];
$folder = "images/testimonial/" . $lis_img;
move_uploaded_file($tempname, $folder);
} else {
$lis_img = $result1["img"];
}
$update_query = "UPDATE testimonials SET title=?, designation=?, descrip=?, descrip_fa=?, title_fa=?, designation_fa=?, img=? WHERE id=?";
$stmt = mysqli_prepare($con, $update_query);
// Bind the parameters
mysqli_stmt_bind_param($stmt, "sssssssi", $title, $designation, $descrip, $descrip_fa, $title_fa, $designation_fa, $lis_img, $testimonial_id);
// Execute the statement
if (mysqli_stmt_execute($stmt)) {
echo "<script>alert('Updated Successfully');</script>";
} else {
echo "<script>alert('Error updating department: " . mysqli_error($con) . "');</script>";
}
echo "<script>window.location.href = 'add-testimonials.php'</script>";
mysqli_stmt_close($stmt);
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title><?php include('title.php') ?></title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="plugins/fontawesome-free/css/all.min.css">
<link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
<link rel="stylesheet" href="dist/css/adminlte.min.css">
<link rel="stylesheet" href="plugins/summernote/summernote-bs4.css">
<link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700" rel="stylesheet">
<link rel="shortcut icon" type="image/png" href="images/fav.png">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/themify-icons.css">
<link rel="stylesheet" href="css/animate.css">
<link rel="stylesheet" href="css/styles.css">
<link rel="stylesheet" href="css/red.css" id="style_theme">
<link rel="stylesheet" href="css/responsive.css">
<link rel="stylesheet" href="charts/css/morris.css">
<link rel="stylesheet" href="css/jquery-jvectormap.css">
<link rel="stylesheet" href="datatable/dataTables.bootstrap4.min.css">
<link rel="stylesheet" href="dist/css/user_css.css">
</head>
<body>
<!-- Pre Loader -->
<!--/Pre Loader -->
<div class="wrapper">
<!-- Sidebar -->
<?php include('sidebar.php') ?>
<!-- /Sidebar -->
<!-- Page Content -->
<div id="content">
<div>
<?php include('topbar.php') ?>
</div>
<div class="row no-margin-padding">
<div class="col-md-6">
<h3 class="block-title">Testimonial</h3>
</div>
<div class="col-md-6">
<ol class="breadcrumb">
<li class="breadcrumb-item">
<a href="index.php">
<span class="ti-home"></span>
</a>
</li>
<li class="breadcrumb-item">Testimonials</li>
</ol>
</div>
</div>
<section class="content-header">
<div class="container-fluid">
<div class="row mb-2 justify-content-center">
<div class="col-sm-6">
<h1>Edit Testimonials / ویرایش نظرات برتر </h1>
</div>
</div>
</div>
</section>
<div class="col-md-15">
<form action="" method="post" enctype="multipart/form-data">
<div class="card card-outline card-info">
<div class="card-header">
<div class="form-group">
<label>Enter Name</label>
<input name="title" value="<?php echo $result1['title']; ?>" type="text" class="form-control" placeholder="Enter ...">
</div>
</div>
<div class="form-group" dir="rtl" style="text-align: right; padding-right: 20px;">
<label for="name">اسم </label>
<input type="text" value="<?php echo $result1['title_fa']; ?>" name="title_fa" class="form-control" placeholder="اسم" id="Doctor-name">
</div>
<div class="card-header">
<div class="form-group">
<label>Enter Designation</label>
<input name="designation" type="text" value="<?php echo $result1['designation']; ?>" class="form-control" placeholder="Enter ...">
</div>
</div>
<div class="form-group" dir="rtl" style="text-align: right; padding-right: 20px;">
<label for="name">مقام </label>
<input value="<?php echo $result1['designation_fa']; ?>" type="text" name="designation_fa" class="form-control" placeholder="مقام">
</div>
<div class="card-body pad">
<label>Comments</label>
<div class="mb-3">
<textarea name="comments" placeholder="comments" style="width: 100%;" rows="5" cols="23"><?php echo $result1['descrip']; ?></textarea>
</div>
</div>
<div class="card-body pad" dir="rtl" style="text-align: right;">
<label dir="rtl">نظر</label>
<div class="mb-3">
<textarea name="comments_fa" placeholder="نظر" style="width: 100%;" rows="5" cols="23"><?php echo $result1['descrip_fa']; ?></textarea>
</div>
</div>
<div class="card-header">
<div class="form-group">
<label for="exampleInputFile">Select Img<span style="color:red;">(only compresed)</span></label>
<p style="color:red;">img size 70px x 70px</p>
<input name="lis_img" type="file" >
</div>
</div>
<div class="card-header">
<div class="form-group">
<div class="row">
<div class="col-sm-6">
<!-- Add the Edit button for each testimonial -->
<button type="submit" name="update" class="btn btn-primary btn-lg">Publish</button>
</div>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
<!-- /Main Content -->
</div>
<!-- /Page Content -->
</div>
<!-- Back to Top -->
<a id="back-to-top" href="#" class="back-to-top">
<span class="ti-angle-up"></span>
</a>
<script src="plugins/jquery/jquery.min.js"></script>
<script src="plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="dist/js/adminlte.min.js"></script>
<script src="dist/js/demo.js"></script>
<script src="plugins/summernote/summernote-bs4.min.js"></script>
<script>
$(function () {
$('.textarea').summernote()
})
</script>
<!-- Popper Library-->
<script src="js/popper.min.js"></script>
<!-- Bootstrap Library-->
<script src="js/bootstrap.min.js"></script>
<!-- Datatable -->
<script src="datatable/jquery.dataTables.min.js"></script>
<script src="datatable/dataTables.bootstrap4.min.js"></script>
<!-- Custom Script-->
<script src="js/custom.js"></script>
</body>
</html>
|