-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddbook.php
70 lines (63 loc) · 1.79 KB
/
addbook.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="shortcut icon" href="logo.ico" />
<title>Add Book</title>
</head>
<body>
<h1>Add Book</h1>
<form method="GET">
Book name: <input type="text" autocomplete="off" name="bookname">
<br><br>
Book code: <input type="text" autocomplete="off" name="id">
<br><br>
Total nos:<input type="text" autocomplete="off" name="total">
<br><br>
<button type="submit">Submit</button>
<!--
avilable will also be equal to total at the beginning
-->
</form>
<br><br>
<button type="button" onclick="window.location.href ='edit.php'">Back to edit page</button>
<?php
if(empty($_GET['bookname'])||empty($_GET['id'])||empty($_GET['total']))
{
echo"Fill the details";
}
else{
$bookname=$_GET['bookname'];
$id=$_GET['id'];
$total=$_GET['total'];
$available=$total;
echo $_GET['bookname']." ".$_GET['id']." ".$_GET['total']." ".$_GET['total'];
$id=$_GET['id'];
$servername="localhost";
$username="id9023615_root";//uname and pass were taken from php myadmin page
$password="pwd54";
$dbname="id9023615_test_pr";
$conn=new mysqli($servername,$username,$password,$dbname);
if(! $conn)
{
die('could not connect'.mysql_error());
}
else
{
$sql="INSERT INTO book_rec
(id,bookname,total_nos,available)
VALUES ('$id','$bookname','$total','$total')";
$retval=mysqli_query($conn,$sql);
if(! $retval ) {
die('Could not add data: ' . mysqli_error($conn));
}
else
echo "Added data successfully\n";
}
}
//now write sql queries to pass these values to the table in the db (done)
?>
</body>
</html>