-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
executable file
·39 lines (38 loc) · 1.02 KB
/
index.php
File metadata and controls
executable file
·39 lines (38 loc) · 1.02 KB
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
33
34
35
36
37
38
39
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>cartoon</title>
</head>
<body>
<?php
$name=trim($_POST['isbn']);
$author=trim($_POST['author']);
$title=trim($_POST['title']);
$price=trim($_POST['price']);
if (!$name) {
echo "you have not entered a bookname";
}
if (!$author) {
echo "you have not entered a author";
}
if (!$phone) {
echo "you have not entered a phone number";
}
@ $db=new mysqli('localhost','root','yy','book');
if (mysqli_connect_errno()) {
echo "error: could not connect to database. please retry latter";
exit;
}
$query="insert into books(bookid,name,author,phone) value('null','$isbn','$author','$title','$price')";
$result=$db->query($query);
if ($result) {
echo $db->affected_rows."book inserted into database";
}
else {
echo "an error has occoured, the item was not added";
}
$db->close();
?>
</body>
</html>