forked from maxsterly43/task1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathedit.php
32 lines (32 loc) · 1.35 KB
/
edit.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 header("Location: http://host1");?>
<html>
<head>
<meta charset = "utf-8">
</head>
<body>
<?php
require "/connectBD.php";
if($_POST["changeBT"]){
$update = "UPDATE books SET name ='{$_POST['ch_name']}', author ='{$_POST['ch_author']}',
price ='{$_POST['ch_price']}', genre ='{$_POST['ch_genre']}'
WHERE codeBook ='{$_POST['ch_codeBook']}'";
$q = mysqli_query($connection, $update) or die("Error".mysqli_error($q));
}
else if($_POST['del']){
$codeBook = preg_replace("/[^0-9]/", '', $_POST['del']);
$del = "DELETE FROM books WHERE codeBook = ".$codeBook;
$q = mysqli_query($connection, $del) or die("Error".mysqli_error($q));
}else if($_POST['addQ']){
$codeBook = 'NULL';
$name = $_POST['name'];
$author = $_POST['author'];
$price = $_POST['price'];
$genre = $_POST['genre'];
$q = "INSERT INTO books (codeBook, name, author, price, genre)
VALUES (".$codeBook.", '".$name."', '".$author."', '".$price."', '".$genre."');";
mysqli_query($connection, $q) or die("Error".mysqli_error($q));
}
exit();
?>
</body>
</html>