tech4biz/admin/api/feedback-report.php
2024-10-24 17:20:08 +05:30

60 lines
2.1 KiB
PHP

<?php
require_once "../db/config.php";
require_once "../includes/functions.php";
$_REQUEST_METHOD = $_SERVER['REQUEST_METHOD'];
$response = array();
// if ($_REQUEST_METHOD === 'POST') {
// $feedback_title = $_POST['feedback_title'];
// $email = $_POST['email'];
// $description = $_POST['description'];
// $image = $_POST['image'];
// $video = $_POST['video'];
// $rating = $_POST['rating'];
// $feedback_type = $_POST['feedback_type'];
// if (isset($connection)) {
// $insertFeedback = $connection->query("INSERT INTO `feedback_report`(`feedback_title`, `email`, `description`, `image`, `video`, `rating`, `feedback_type`) VALUES ('$feedback_title','$email','$description','$image','$video','$rating','$feedback_type')");
// }
// } else {
// $response["message"] = "INVALID REQUEST";
// $response["status"] = 400;
// }
if ($_REQUEST_METHOD === 'POST') {
$feedback_title = $_POST['feedback_title'];
$email = $_POST['email'];
$description = $_POST['description'];
// $image = $_POST['image'];
$video = $_POST['thirdVideo'];
$rating = $_POST['rating'];
$feedback_type = $_POST['feedback_type'];
if (is_uploaded_file($_FILES['image']['tmp_name'])) {
$tmp_file1 = $_FILES['image']['tmp_name'];
$post_name = $_FILES['image']['name'];
$extension1 = explode(".", $post_name);
$unix_ms_time1 = intval(microtime(true) * 1000);
$inputed_post = $unix_ms_time1 . '.' . end($extension1);
$upload_dir1 = "./feedback_image/" . $inputed_post;
move_uploaded_file($tmp_file1, $upload_dir1);
}
if (isset($connection)) {
$insertFeedback = $connection->query("INSERT INTO `feedback_report`(`feedback_title`, `email`, `description`, `video`, `rating`, `feedback_type`) VALUES ('$feedback_title','$email','$description', '$video','$rating','$feedback_type')");
if($insertFeedback){
$response["message"] = "Successfully saved";
$response["status"] = 200;
}
}
} else {
$response["message"] = "Invalid request";
$response["status"] = 400;
}
echo json_encode($response);