D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
realadss
/
.trash
/
admin
/
Filename :
testimonial-form.php
back
Copy
<?php include('include/header.php'); if(isset($_POST['update'])){ $id = $_POST['idd']; $headline = $_POST['headline']; $inputProductDescription = $_POST['details']; $replaceArray0 = array( '"' => """, "'" => "'", ); $modifiedText0 = str_replace(array_keys($replaceArray0), array_values($replaceArray0), $inputProductDescription); $image_name = $_POST['imageold']; $image01 = $_FILES['image']['name']; if(!empty($image01)){ $image1 = $image_name; $stmp_name1 = $_FILES['image']['tmp_name']; move_uploaded_file($stmp_name1, "images/preloaders/".$image1); }else{ $image1=$image_name; } $sql = "UPDATE `testimonial` SET `name`='$headline',`image`='$image1',`content`='$modifiedText0' WHERE id = '$id'"; $data= mysqli_query($conn, $sql); if($data){ echo "<script> alert('Data Updated');window.location.href='testimonial.php'</script>"; } else{ echo "<script> alert('Please try again')</script>"; } } if(isset($_POST['add'])){ $headline = $_POST['headline']; $inputProductDescription = $_POST['details']; $replaceArray0 = array( '"' => """, "'" => "'", ); $modifiedText0 = str_replace(array_keys($replaceArray0), array_values($replaceArray0), $inputProductDescription); if(!empty($_FILES['image'])){ $temp = $_FILES['image']['tmp_name']; $date = date('y-m-d-H-i-s'); $filename = $date."timage.png"; move_uploaded_file($temp, 'images/preloaders/'.$filename); }else{ echo 'fail'; die(); } $sqli = "INSERT INTO `testimonial`(`name`, `image`, `content`) VALUES ('$headline','$filename','$modifiedText0')"; $data= mysqli_query($conn, $sqli); if($data){ echo "<script> alert('Item Added');window.location.href='testimonial-form.php'</script>"; } else{ echo "<script> alert('Please try again')</script>"; } } ?> <!-- Content Wrapper. Contains page content --> <div class="content-wrapper"> <div class="container-full"> <!-- Content Header (Page header) --> <div class="content-header"> <div class="d-flex align-items-center"> <div class="me-auto"> <h4 class="page-title">Add Testimonials</h4> <!--<div class="d-inline-block align-items-center">--> <!-- <nav>--> <!-- <ol class="breadcrumb">--> <!-- <li class="breadcrumb-item"><a href="#"><i class="mdi mdi-home-outline"></i></a></li>--> <!-- <li class="breadcrumb-item" aria-current="page">Pages</li>--> <!-- <li class="breadcrumb-item active" aria-current="page">Add Category</li>--> <!-- </ol>--> <!-- </nav>--> <!--</div>--> </div> </div> </div> <?php $id = ''; if(isset($_GET['id'])){ $id = $_GET['id']; $selectsql = mysqli_query($conn, "select * from testimonial where id = '$id'"); $datasql = mysqli_fetch_array($selectsql); } ?> <!-- Main content --> <section class="content"> <div class="box"> <div class="box-header with-border"> <h4 class="box-title">Add Testimonials</h4> </div> <!-- /.box-header --> <div class="box-body"> <form role="form" method="POST" enctype="multipart/form-data"> <!-- text input --> <div class="form-group"> <label class="form-label">Name</label> <input type="text" class="form-control" placeholder="Headline" value="<?= $datasql['name'] ?? "";?>" name="headline" required> <input type="hidden" value="<?= $id;?>" name="idd"> </div> <div class="form-group"> <label class="form-label">Image</label> <input type="file" class="form-control" placeholder="Enter Category...." name="image" > <input type="hidden" class="form-control" value="<?= $datasql['image'] ?? "";?>" name="imageold" > <?php if($id != ''){?> <img src="images/preloaders/<?= $datasql['image'];?>" height="100px"/> <?php } ?> </div> <div class="form-group"> <label class="form-label">Comment</label><br> <textarea class="form-control" name="details" required><?= $datasql['content'] ?? "";?></textarea> </div> <div class="box-footer"> <?php if($id == ''){?> <button type="submit" class="btn btn-success" name="add">Add</button> <?php }else{ ?> <button type="submit" class="btn btn-success" name="update">Update</button> <?php } ?> </div> </form> </div> <!-- /.box-body --> </div> </section> <!-- /.content --> </div> </div> <!-- /.content-wrapper --> <?php include('include/footer.php') ?>