-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprocess.php
32 lines (32 loc) · 1.35 KB
/
process.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
31
32
<?php
include('connect.php');
if (isset($_POST["create"])) {
$title = mysqli_real_escape_string($conn, $_POST["title"]);
$type = mysqli_real_escape_string($conn, $_POST["type"]);
$author = mysqli_real_escape_string($conn, $_POST["author"]);
$description = mysqli_real_escape_string($conn, $_POST["description"]);
$sqlInsert = "INSERT INTO books(title , author , type , description) VALUES ('$title','$author','$type', '$description')";
if(mysqli_query($conn,$sqlInsert)){
session_start();
$_SESSION["create"] = "Book Added Successfully!";
header("Location:index.php");
}else{
die("Something went wrong");
}
}
if (isset($_POST["edit"])) {
$title = mysqli_real_escape_string($conn, $_POST["title"]);
$type = mysqli_real_escape_string($conn, $_POST["type"]);
$author = mysqli_real_escape_string($conn, $_POST["author"]);
$description = mysqli_real_escape_string($conn, $_POST["description"]);
$id = mysqli_real_escape_string($conn, $_POST["id"]);
$sqlUpdate = "UPDATE books SET title = '$title', type = '$type', author = '$author', description = '$description' WHERE id='$id'";
if(mysqli_query($conn,$sqlUpdate)){
session_start();
$_SESSION["update"] = "Book Updated Successfully!";
header("Location:index.php");
}else{
die("Something went wrong");
}
}
?>