-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdelete.php
30 lines (28 loc) · 1.03 KB
/
delete.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
include("connect.php");
if (isset($_GET['id'])) {
$id = $_GET['id'];
$checkid = $conn->prepare("select * from crud where id = '" . $id . "'"); // to check id
$checkid->execute();
if ($checkid->rowCount() > 0) {
$insert_query = $conn->prepare("delete from crud where id = :id"); //to insert data
try {
$conn->beginTransaction();
$insert_query->bindParam(":id", $id);
$count = $insert_query->execute();
if ($count> 0) {
header("Location: index.php?message=Record has been Deleted successfully"); //success data insertion
} else {
header("Location: index.php?message=Failed to Delete"); //failure data insertion
}
$conn->commit();
}
catch (PDOExecption $e) {
$dbh->rollback();
print "Error!: " . $conn->getMessage() . "</br>"; //exception
}
} else {
header("Location: index.php?message=Invalid Request");
}
}
?>