Server IP : 184.154.167.98 / Your IP : 3.147.74.100 Web Server : Apache System : Linux pink.dnsnetservice.com 4.18.0-553.22.1.lve.1.el8.x86_64 #1 SMP Tue Oct 8 15:52:54 UTC 2024 x86_64 User : puertode ( 1767) PHP Version : 7.2.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/puertode/public_html/oficios/backend/ |
Upload File : |
<?php include 'database.php'; if(count($_POST)>0){ if($_POST['type']==1){ $name=$_POST['name']; $email=$_POST['email']; $phone=$_POST['phone']; $city=$_POST['city']; $sql = "INSERT INTO `crud`( `name`, `email`,`phone`,`city`) VALUES ('$name','$email','$phone','$city')"; if (mysqli_query($conn, $sql)) { echo json_encode(array("statusCode"=>200)); } else { echo "Error: " . $sql . "<br>" . mysqli_error($conn); } mysqli_close($conn); } } if(count($_POST)>0){ if($_POST['type']==2){ $id=$_POST['id']; $name=$_POST['name']; $email=$_POST['email']; $phone=$_POST['phone']; $city=$_POST['city']; $sql = "UPDATE `crud` SET `name`='$name',`email`='$email',`phone`='$phone',`city`='$city' WHERE id=$id"; if (mysqli_query($conn, $sql)) { echo json_encode(array("statusCode"=>200)); } else { echo "Error: " . $sql . "<br>" . mysqli_error($conn); } mysqli_close($conn); } } if(count($_POST)>0){ if($_POST['type']==3){ $id=$_POST['id']; $sql = "DELETE FROM `crud` WHERE id=$id "; if (mysqli_query($conn, $sql)) { echo $id; } else { echo "Error: " . $sql . "<br>" . mysqli_error($conn); } mysqli_close($conn); } } if(count($_POST)>0){ if($_POST['type']==4){ $id=$_POST['id']; $sql = "DELETE FROM crud WHERE id in ($id)"; if (mysqli_query($conn, $sql)) { echo $id; } else { echo "Error: " . $sql . "<br>" . mysqli_error($conn); } mysqli_close($conn); } } ?>