-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInsertCart.php
More file actions
56 lines (47 loc) · 1.54 KB
/
InsertCart.php
File metadata and controls
56 lines (47 loc) · 1.54 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<html>
<head>
<meta http-equiv='Content-Type' content='text/html' ; charset='utf-8'>
</head>
<body>
<?php
$isbn = $_POST ['ISBN'];
$book_title = $_POST ['book_title'];
$book_author = $_POST ['book_author'];
$book_price = $_POST ['book_price'];
$hope_price = $_POST ['hope_price'];
$book_publisher = $_POST ['book_publisher'];
$id = 'root';
$pw = 'apmsetup';
if (! $isbn || ! $book_title || ! $book_author || ! $book_price || ! $hope_price || ! $book_publisher) {
echo 'You have not entered all the required details.<br/>' . 'Please go back and try again.';
exit ();
}
echo "test<br>";
if (! get_magic_quotes_gpc ()) {
$isbn = addslashes ( $isbn );
$book_title = addslashes ( $book_title );
$book_author = addslashes ( $book_author );
$book_price = doubleval ( $book_price );
$hope_price = doubleval ( $hope_price );
$book_publisher = addslashes ( $book_publisher );
}
$db = mysqli_connect ( 'localhost', $id, $pw, 'book' );
mysqli_query ( $db, "set names utf8" );
if (mysqli_connect_errno ()) {
echo 'Error: Could not connect to database. Please try again later.';
exit ();
}
$query = "insert into bookcart values ('" . $isbn . "', '" . $book_title . "', '" . $book_author . "', '" . $book_price . "', '" . $hope_price . "', '" . $book_publisher . "')";
$result = mysqli_query ( $db, $query ) or die ( 'Error connecting to MySQL server.' );
if ($result) {
echo sucess;
}
mysqli_close ( $db );
echo ("
<script>
history.go(-1)
</script>
");
?>
</body>
</html>