farfnd

delete.php

Dec 10th, 2021
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.65 KB | None | 0 0
  1. <?php
  2.  
  3. include("config.php");
  4.  
  5. header("Access-Control-Allow-Origin: *");
  6. header("Access-Control-Allow-Headers: *");
  7. header("Access-Control-Allow-Methods: *");
  8.  
  9. if($_SERVER['REQUEST_METHOD'] == 'GET'){
  10.     $id = str_replace("'", "\'", $_GET['id']);
  11.  
  12.     $sql = "DELETE FROM calon_siswa
  13.            WHERE id=$id";
  14.     $query = mysqli_query($db, $sql);
  15.     if ($query) {
  16.         die(json_encode([
  17.             "error" => 0,
  18.             "status" => "OK"
  19.         ]));
  20.     } else {
  21.         die(json_encode([
  22.             "error" => 500,
  23.             "status" => "Internal Server Error"
  24.         ]));
  25.     }
  26. }else{
  27.     die("Method not allowed");
  28. }
Advertisement
Add Comment
Please, Sign In to add comment