0% found this document useful (0 votes)
130 views53 pages

Books PHP

This document provides an overview of an online book shopping project. It includes sections on the purpose, modules, users, hardware and software requirements, and advantages of the project. The key components are implementing user registration and login, allowing users to choose and buy books, and using PHP and MySQL to build the website and database. The project will create a centralized online bookstore for students and others to conveniently purchase books online.

Uploaded by

V.M.B.S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
130 views53 pages

Books PHP

This document provides an overview of an online book shopping project. It includes sections on the purpose, modules, users, hardware and software requirements, and advantages of the project. The key components are implementing user registration and login, allowing users to choose and buy books, and using PHP and MySQL to build the website and database. The project will create a centralized online bookstore for students and others to conveniently purchase books online.

Uploaded by

V.M.B.S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 53

ONLINE BOOKS SHOPPING 6 TH SEM BCA 2022/23

A Project Report On
Online Book Shopping

1
ONLINE BOOKS SHOPPING 6 TH SEM BCA 2022/23

TABLE OF CONTENT

Contents Page no.


1. Introduction 6
1.1. Purpose 6
1.2. Modules 7
1.3. Users 7
1.4. Hardware requirement 7

1.5. Software requirement 7


1.6. Advantages 8
1.7. Applications 8

2.0. Overall description 8

2.1. Administrator 8
3.0.Web development 9
4.0.What is PHP. 9
5.0.What is MySql database. 10
6.0. Integrating the Website and Database 11

7.0. The Shopping Cart Application 11

8.0. Project Design 12


9.0. Functional Decomposition Diagram 12-13
10.0. Data Flow Diagram (DFD) 14-19

11.0. Input & Output Snapshots 20-25


12.0. Coding 26-49
13.0. Testing,limitations,Conclusion 50
14.0. Links and source 53

2
ONLINE BOOKS SHOPPING 6 TH SEM BCA 2022/23

Introduction
An online bookstore software projects that acts as a central database containing
various books in stock along with their title, author and cost. This project is a
website that acts as a central book store. This web project is developed using php
as the front end and sql as a back-end. The sql database stores various book
related details. A user visiting the website can see a wide range of books
arranged in respective categories. The user may select desired book and view its
price. The user may even search for specific books on the website. Once the user
selects a book , he then has to fill in a form and the book is booked for the user.
The software has the following three main components:-

1. Implement of new user to register and login.

2. Implement user to choose any book.

3. Implement the user to buy books.

The website will be implemented using PHP as the programming


language.MYSQL database wil be used to link database.

Purpose
For the project, we propose to build an online bookshop for People. The online
bookshop will contain stories, study material, any courses books like computer and
be available to everyone. Many students find textbooks too expensive to buy at
school bookstores and many courses only use the required textbooks a few days in
a semester. This becomes very wasteful and frustrating for students & others
people. This online bookstore provides a solution to this. It will provide a service
in which students can buy books online without any treble. There will be free
shipping. They do need to register with the site in order to books. Payment
information will be requested after adding any numbers of books in the cart.
.

3
ONLINE BOOKS SHOPPING 6 TH SEM BCA 2022/23

Modules
The site will contain the following features:
 Registration / Login
 Add to Cart
 Searching for book
 Buy book
 Payment option

Users:
Register-The user needs to be registered in order to login.

Login: The users need to login in to get access to the system.

View product-Here the user can view different products and its details.

Search –The user can search product by name after which the system will evaluate
prices of the same product from different websites to give the user the best search
result.

Hardware Requirements:
 Processor – i3
 Hard Disk – 50 GB
 Memory – 1GB RAM
 Monitor

Software Requirement:

 Windows 7 or higher
 XAMMP control panel
 Note pade ++
 My SQL

4
ONLINE BOOKS SHOPPING 6 TH SEM BCA 2022/23

Advantages:
 Customers can get their book delivered instead of actually going and buying
the book. They can make payment online itself.
 Managing of inventory in the shop for shopkeeper becomes easier as
customers are not visiting and ordering online.
 This system saves both time and travelling cost of customers.
 User can get to know different kinds of books that they were unaware of by
just searching in the system using keywords.

Applications:
 The system can be very well used by the book shopkeepers to expand their
customers.

OVERALL DESCRIPTION
This project designs an online bookstore provides a web-based interface. It is the
graphical user interface. It have a form for user to input query information to
search the database. The users interface then pass the input to the control function,
which implemented in php. The control function is designed to process the input
from the users interface, generate the searching query and then gets data from the
database and returns to the users interface. The control functions also have bridges
to search some external real online bookshops. It can generate the query based on
the user input and pass them to the commercial bookshop. The bridge can also
handle the response from the commercial bookshop and parse the useful
information and display to the user in HTML forms.

For Administrators

 Taking backup of the Database .


 Editing / Deleting / Creating the database .
 Changing the password .

5
ONLINE BOOKS SHOPPING 6 TH SEM BCA 2022/23

3.0. What is web development.


Web development broadly refers to the tasks associated with developing
websites for hosting via intranet or internet. The web development process
includes web design, web content development, client-side/server-side scripting
and network security configuration, among other tasks. Web development is also
known as website development.

4.0. What is PHP.


PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used open
source general-purpose scripting language that is especially suited for web
development and can be embedded into HTML.
<!DOCTYPE HTML>
<html>
<head>
<title>Example</title>
</head>
<body>

<?php
echo "Hi, I'm a PHP script!";
?>

</body>
</html>

Advantages:
Stable: Since it is maintained by many developers, so when bugs are found, it can
be quickly fixed.

Easy to use: It uses C like syntax, so for those who are familiar with C, it’s very
easy for them to pick up and it is very easy to create website scripts.

Speed: It is relative fast since it uses much system resource.

6
ONLINE BOOKS SHOPPING 6 TH SEM BCA 2022/23

What is MySql database.


In this project, MySQL is used as the backend database. MySQL is an open source
database management system. The features of MySQL are given below:
 MySQL is a relational database management system. A relational database
stores information in different tables, rather than in one giant table. These
tables can be referenced to each other, to access and maintain data easily.
 MySQL is open source database system. The database software can be used
and modify by anyone according to their needs. It is fast, reliable and easy to
use. To improve the performance.
 MySQL is multithreaded database engine. A multithreaded application
performs many tasks at the same time as if multiple instances of that
application were running simultaneously.
 In being multithreaded MySQL has many advantages. A separate thread
handles each incoming connection with an extra thread that is always
running to manage the connections. Multiple clients can perform read
operations simultaneously, but while writing, only hold up another client
that needs access to the data being updated. Even though the threads share
the same process space, they execute individually and because of this
separation, multiprocessor machines can spread the thread across many
CPUs as long as the host operating system supports multiple CPUs.
Multithreading is the key feature to support MySQL’s performance design
goals. It is the core feature around which MySQL is built.
 MySQL database is connected to JSP using an ODBC driver. Open
Database Connectivity (ODBC) is a widely accepted application-
programming interface (API) for database access. The ODBC driver is a
library that implements the functions supported by ODBC API. It processes
ODBC function calls, submits SQL requests to MySQL server, and returns
results back to the application. If necessary, the driver modifies an
application's request so that the request conforms to syntax supported by
MySQL.

7
ONLINE BOOKS SHOPPING 6 TH SEM BCA 2022/23

DATABASE TABLES

ADMIBTb

BOOKSTb

CUSTOMERTb

8
ONLINE BOOKS SHOPPING 6 TH SEM BCA 2022/23

ORDERTb

PUBLISHERid

6.0. Integrating the Website and Database


Customers ordering from an e-commerce website need to be able to get
information about a vendor’s products and services, ask questions, select items
they wish to purchase, and submit payment information. Vendors need to be able
to track customer inquiries and preferences and process their orders. So a well
organized database is essential for the development and maintenance of an e-
commerce site. In a static Web page, content is determined at the time when the
page is created. As users access a static page, the page always displays the same
information. Example of a static Web page is the page displaying company
information. In a dynamic Web page, content varies based on user input and data
received from external sources. We use the term “data-based Web pages” to refer
to dynamic Web pages deriving some or all of their content from data files or
databases. A data-based Web page is requested when a user clicks a hyperlink or
the submit button on a Web page form. If the request comes from clicking a
hyperlink, the link specifies either a Web server program or a Web page that calls a
Web server program. In some cases, the program performs a static query, such as
“Display all items from the Inventory”. Although this query requires no user input,
the results vary depending on when the query is made. If the request is generated
when the user clicks a form’s submit button, instead of a hyperlink, the Web server
program typically uses the form inputs to create a query. For example, the user
might select five books to be purchased and then submit the input to the Web
server program. The Web server program then services the order, generating a
9
ONLINE BOOKS SHOPPING 6 TH SEM BCA 2022/23

dynamic Web page response to confirm the transaction. In either case, the Web
server is responsible for formatting the query results by adding HTML tags. The
Web server program then sends the program’s output back to the client’s browser
as a Web page.

7.0. The Shopping Cart Application

The objective of this application is to provide the user an online website where
they can buy books from the comfort of their home. A shopping cart is used for the
purpose. The user can select the desired books, place them in the shopping cart and
purchase them using a Credit Card. The user’s order will be shipped according to
the type of shipping selected at the time of placing the order.

10
ONLINE BOOKS SHOPPING 6 TH SEM BCA 2022/23

8.0. Project Design

In order to design a web site, the relational database must be designed first.
Conceptual design can be divided into two parts: The data model and the process
model. The data model focuses on what data should be stored in the database while
the process model deals with how the data is processed. To put this in the context
of the relational database, the data model is used to design the relational tables.
The process model is used to design the queries that will access and perform
operations on those tables.

9.0. Functional Decomposition Diagram

A decomposition diagram shows a top-down functional decomposition of a system


and exposes the system's structure. The objective of the Functional Decomposition
is to break down a system step by step, beginning with the main function of a
system and continuing with the interim levels down to the level of elementary
functions. The diagram is the starting point for more detailed process diagrams,
such as data flow diagrams (DFD). shows the Functional Decomposition Diagram
for this project.

11
ONLINE BOOKS SHOPPING 6 TH SEM BCA 2022/23

12
ONLINE BOOKS SHOPPING 6 TH SEM BCA 2022/23

Data Flow Diagram (DFD)


Data Flow Diagrams show the flow of data from external entities into the system,
and from one process to another within the system. There are four symbols for
drawing a DFD:
1. Rectangles representing external entities, which are sources or
destinations of data.
2. Ellipses representing processes, which take data as input, validate and
process it and output it.
3. Arrows representing the data flows, which can either, be electronic data
or physical items.
4. Open-ended rectangles or a Disk symbol representing data stores,
including electronic stores such as databases or XML files and physical
stores such as filing cabinets or stacks of paper.

13
ONLINE BOOKS SHOPPING 6 TH SEM BCA 2022/23

14
ONLINE BOOKS SHOPPING 6 TH SEM BCA 2022/23

ER NOTATION

Entity Relationship Diagram (ERD) Symbols and Notations. There are three basic
elements in an ER Diagram: entity, attribute, relationship. There are more elements
which are based on the main elements. They are weak entity, multi valued attribute,
derived attribute, weak relationship, and recursive relationship.

Conceptual ER diagram symbols


Conceptual Data Models establish a broad view of what should be included in the
model set. Conceptual ERDs can be used as the foundation for logical data models.
They may also be used to form commonality relationships between ER models as a
basis for data model integration. All of the symbols shown below are found in the UML
Entity Relationship and Entity Relationship shape library of Lucidchart.

ERD entity symbols

Entities are objects or concepts that represent important data. Entities are typically
nouns such as product, customer, location, or promotion. There are three types of
entities commonly used in entity relationship diagrams.

Entity Symbol Name Description

These shapes are independent from other


entities, and are often called parent entities,
Strong since they will often have weak entities that
entity depend on them. They will also have a
primary key, distinguishing each
occurrence of the entity.

15
ONLINE BOOKS SHOPPING 6 TH SEM BCA 2022/23

Entity Symbol Name Description

Weak entities depend on some other entity


type. They don't have primary keys, and
Weak entity
have no meaning in the diagram without
their parent entity.

Associative entities relate the instances of several


Associative
entity types. They also contain attributes specific
entity
to the relationship between those entity instances.

ERD relationship symbols

Within entity-relationship diagrams, relationships are used to document the interaction


between two entities. Relationships are usually verbs such as assign, associate, or track
and provide useful information that could not be discerned with just the entity types.

Relationships are associations between or


Relationship
among entities.

16
ONLINE BOOKS SHOPPING 6 TH SEM BCA 2022/23

Weak Weak Relationships are connections


relationship between a weak entity and its owner.

ERD attribute symbols

ERD attributes are characteristics of the entity that help users to better understand the
database. Attributes are included to include details of the various entities that are
highlighted in a conceptual ER diagram.

Attribute Symbol Name Description

Attributes are characteristics of an


Attribute entity, a many-to-many relationship, or a
one-to-one relationship.

Multivalued Multivalued attributes are those that are


attribute can take on more than one value.

17
ONLINE BOOKS SHOPPING 6 TH SEM BCA 2022/23

Attribute Symbol Name Description

Derived attributes are attributes whose


Derived
attribute
value can be calculated from related
attribute values.

Relationships are associations between


Relationship
or among entities.

18
ONLINE BOOKS SHOPPING 6 TH SEM BCA 2022/23

ER DIAGRAM
address name
name address

phone
url
author publisher
url

Written by Published by

email
year address

phone

title book name


number customer
Basket_
price id
ISBN
Basket_of
contains

Shoping basket

stocks warehouse

address code

number
phone

19
ONLINE BOOKS SHOPPING 6 TH SEM BCA 2022/23

11.0. Input & Output Screenshots

Home page

PUBLISHERS

20
ONLINE BOOKS SHOPPING 6 TH SEM BCA 2022/23

CONTACT US

21
ONLINE BOOKS SHOPPING 6 TH SEM BCA 2022/23

CART

22
ONLINE BOOKS SHOPPING 6 TH SEM BCA 2022/23

ADMIN LOGIN

ADD BOOKS

23
ONLINE BOOKS SHOPPING 6 TH SEM BCA 2022/23

24
ONLINE BOOKS SHOPPING 6 TH SEM BCA 2022/23

PAYMENT

CARD DETAILS

25
ONLINE BOOKS SHOPPING 6 TH SEM BCA 2022/23

CODING

Admin.php
<?php
$title = "Administration section";
require_once "./template/header.php";
?>

<form class="form-horizontal" method="post" action="admin_verify.php">


<div class="form-group">
<label for="name" class="control-label col-md-
4">Name</label>
<div class="col-md-4">
<input type="text" name="name" class="form-control">
</div>
</div>
<div class="form-group">
<label for="pass" class="control-label col-md-4">Pass</label>
<div class="col-md-4">
<input type="password" name="pass" class="form-
control">
</div>
</div>
<input type="submit" name="submit" class="btn btn-primary">
</form>

<?php
require_once "./template/footer.php";
?>

26
ONLINE BOOKS SHOPPING 6 TH SEM BCA 2022/23

Admin add.php

<?php
session_start();
require_once "./functions/admin.php";
$title = "Add new book";
require "./template/header.php";
require "./functions/database_functions.php";
$conn = db_connect();

if(isset($_POST['add'])){
$isbn = trim($_POST['isbn']);
$isbn = mysqli_real_escape_string($conn, $isbn);

$title = trim($_POST['title']);
$title = mysqli_real_escape_string($conn, $title);

$author = trim($_POST['author']);
$author = mysqli_real_escape_string($conn, $author);

$descr = trim($_POST['descr']);
$descr = mysqli_real_escape_string($conn, $descr);

$price = floatval(trim($_POST['price']));
$price = mysqli_real_escape_string($conn, $price);
$publisher = trim($_POST['publisher']);
$publisher = mysqli_real_escape_string($conn, $publisher);

// add image
if(isset($_FILES['image']) && $_FILES['image']['name'] != ""){
$image = $_FILES['image']['name'];
$directory_self =
str_replace(basename($_SERVER['PHP_SELF']), '', $_SERVER['PHP_SELF']);

27
ONLINE BOOKS SHOPPING 6 TH SEM BCA 2022/23

$uploadDirectory = $_SERVER['DOCUMENT_ROOT'] .
$directory_self . "bootstrap/img/";
$uploadDirectory .= $image;
move_uploaded_file($_FILES['image']['tmp_name'],
$uploadDirectory);
}

// find publisher and return pubid


// if publisher is not in db, create new
$findPub = "SELECT * FROM publisher WHERE publisher_name =
'$publisher'";
$findResult = mysqli_query($conn, $findPub);
if(!$findResult){
// insert into publisher table and return id
$insertPub = "INSERT INTO publisher(publisher_name)
VALUES ('$publisher')";
$insertResult = mysqli_query($conn, $insertPub);
if(!$insertResult){
echo "Can't add new publisher " . mysqli_error($conn);
exit;
}
$publisherid = mysql_insert_id($conn);
} else {
$row = mysqli_fetch_assoc($findResult);
$publisherid = $row['publisherid'];
}

$query = "INSERT INTO books VALUES ('" . $isbn . "', '" . $title . "',
'" . $author . "', '" . $image . "', '" . $descr . "', '" . $price . "', '" . $publisherid . "')";
$result = mysqli_query($conn, $query);
if(!$result){
echo "Can't add new data " . mysqli_error($conn);
exit;
28
ONLINE BOOKS SHOPPING 6 TH SEM BCA 2022/23

} else {
header("Location: admin_book.php");
}
}
?>
<form method="post" action="admin_add.php" enctype="multipart/form-
data">
<table class="table">
<tr>
<th>ISBN</th>
<td><input type="text" name="isbn"></td>
</tr>
<tr>
<th>Title</th>
<td><input type="text" name="title" required></td>
</tr>
<tr>
<th>Author</th>
<td><input type="text" name="author" required></td>
</tr>
<tr>
<th>Image</th>
<td><input type="file" name="image"></td>
</tr>
<tr>
<th>Description</th>
<td><textarea name="descr" cols="40"
rows="5"></textarea></td>
</tr>
<tr>
<th>Price</th>
<td><input type="text" name="price" required></td>
</tr>
<tr>
29
ONLINE BOOKS SHOPPING 6 TH SEM BCA 2022/23

<th>Publisher</th>
<td><input type="text" name="publisher" required></td>
</tr>
</table>
<input type="submit" name="add" value="Add new book" class="btn
btn-primary">
<input type="reset" value="cancel" class="btn btn-default">
</form>
<br/>
<?php
if(isset($conn)) {mysqli_close($conn);}
require_once "./template/footer.php";
?>

Admin book.php

<?php
session_start();
require_once "./functions/admin.php";
$title = "List book";
require_once "./template/header.php";
require_once "./functions/database_functions.php";
$conn = db_connect();
$result = getAll($conn);
?>
<p class="lead"><a href="admin_add.php">Add new book</a></p>
<a href="admin_signout.php" class="btn btn-primary">Sign out!</a>
<table class="table" style="margin-top: 20px">
<tr>
<th>ISBN</th>
<th>Title</th>
<th>Author</th>
<th>Image</th>

30
ONLINE BOOKS SHOPPING 6 TH SEM BCA 2022/23

<th>Description</th>
<th>Price</th>
<th>Publisher</th>
<th>&nbsp;</th>
<th>&nbsp;</th>
</tr>
<?php while($row = mysqli_fetch_assoc($result)){ ?>
<tr>
<td><?php echo $row['book_isbn']; ?></td>
<td><?php echo $row['book_title']; ?></td>
<td><?php echo $row['book_author']; ?></td>
<td><?php echo $row['book_image']; ?></td>
<td><?php echo $row['book_descr']; ?></td>
<td><?php echo $row['book_price']; ?></td>
<td><?php echo getPubName($conn, $row['publisherid']);
?></td>
<td><a href="admin_edit.php?bookisbn=<?php echo
$row['book_isbn']; ?>">Edit</a></td>
<td><a href="admin_delete.php?bookisbn=<?php echo
$row['book_isbn']; ?>">Delete</a></td>
</tr>
<?php } ?>
</table>

<?php
if(isset($conn)) {mysqli_close($conn);}
require_once "./template/footer.php";
?>

31
ONLINE BOOKS SHOPPING 6 TH SEM BCA 2022/23

Books.php

<?php
session_start();
$book_isbn = $_GET['bookisbn'];
// connecto database
require_once "./functions/database_functions.php";
$conn = db_connect();

$query = "SELECT * FROM books WHERE book_isbn = '$book_isbn'";


$result = mysqli_query($conn, $query);
if(!$result){
echo "Can't retrieve data " . mysqli_error($conn);
exit;
}

$row = mysqli_fetch_assoc($result);
if(!$row){
echo "Empty book";
exit;
}
$title = $row['book_title'];
require "./template/header.php";
?>
<!-- Example row of columns -->
<p class="lead" style="margin: 25px 0"><a href="books.php">Books</a> >
<?php echo $row['book_title']; ?></p>
<div class="row">
<div class="col-md-3 text-center">
<img class="img-responsive img-thumbnail" src="./bootstrap/img/<?php
echo $row['book_image']; ?>">
</div>
<div class="col-md-6">
<h4>Book Description</h4>
32
ONLINE BOOKS SHOPPING 6 TH SEM BCA 2022/23

<p><?php echo $row['book_descr']; ?></p>


<h4>Book Details</h4>
<table class="table">
<?php foreach($row as $key => $value){
if($key == "book_descr" || $key == "book_image" || $key == "publisherid"
|| $key == "book_title"){
continue;
}
switch($key){
case "book_isbn":
$key = "ISBN";
break;
case "book_title":
$key = "Title";
break;
case "book_author":
$key = "Author";
break;
case "book_price":
$key = "Price";
break;
}
?>
<tr>
<td><?php echo $key; ?></td>
<td><?php echo $value; ?></td>
</tr>
<?php
}
if(isset($conn)) {mysqli_close($conn); }
?>
</table>
<form method="post" action="cart.php">

33
ONLINE BOOKS SHOPPING 6 TH SEM BCA 2022/23

<input type="hidden" name="bookisbn" value="<?php echo


$book_isbn;?>">
<input type="submit" value="Purchase / Add to cart" name="cart"
class="btn btn-primary">
</form>
</div>
</div>
<?php
require "./template/footer.php";
?>

Cart.php
<?php
// the shopping cart needs sessions, to start one
/*
Array of session(
cart => array (
book_isbn (get from $_POST['book_isbn']) => number of
books
),
items => 0,
total_price => '0.00'
)
*/
session_start();
require_once "./functions/database_functions.php";
require_once "./functions/cart_functions.php";

// book_isbn got from form post method, change this place later.
if(isset($_POST['bookisbn'])){
$book_isbn = $_POST['bookisbn'];
}
if(isset($book_isbn)){
// new iem selected
34
ONLINE BOOKS SHOPPING 6 TH SEM BCA 2022/23

if(!isset($_SESSION['cart'])){
// $_SESSION['cart'] is associative array that bookisbn => qty
$_SESSION['cart'] = array();

$_SESSION['total_items'] = 0;
$_SESSION['total_price'] = '0.00';
}

if(!isset($_SESSION['cart'][$book_isbn])){
$_SESSION['cart'][$book_isbn] = 1;
} elseif(isset($_POST['cart'])){
$_SESSION['cart'][$book_isbn]++;
unset($_POST);
}
}

// if save change button is clicked , change the qty of each bookisbn


if(isset($_POST['save_change'])){
foreach($_SESSION['cart'] as $isbn =>$qty){
if($_POST[$isbn] == '0'){
unset($_SESSION['cart']["$isbn"]);
} else {
$_SESSION['cart']["$isbn"] = $_POST["$isbn"];
}
}
}

// print out header here


$title = "Your shopping cart";
require "./template/header.php";

if(isset($_SESSION['cart']) && (array_count_values($_SESSION['cart']))){


$_SESSION['total_price'] = total_price($_SESSION['cart']);

35
ONLINE BOOKS SHOPPING 6 TH SEM BCA 2022/23

$_SESSION['total_items'] = total_items($_SESSION['cart']);
?>
<form action="cart.php" method="post">
<table class="table">
<tr>
<th>Item</th>
<th>Price</th>
<th>Quantity</th>

<th>Total</th>
</tr>
<?php
foreach($_SESSION['cart'] as $isbn => $qty){
$conn = db_connect();
$book =
mysqli_fetch_assoc(getBookByIsbn($conn, $isbn));
?>
<tr>
<td><?php echo $book['book_title'] . " by " .
$book['book_author']; ?></td>
<td><?php echo "$" . $book['book_price']; ?></td>
<td><input type="text" value="<?php echo $qty; ?>"
size="2" name="<?php echo $isbn; ?>"></td>
<td><?php echo "$" . $qty * $book['book_price'];
?></td>
</tr>
<?php } ?>
<tr>
<th>&nbsp;</th>
<th>&nbsp;</th>
<th><?php echo $_SESSION['total_items']; ?></th>
<th><?php echo "$" . $_SESSION['total_price']; ?></th>
</tr>
</table>
36
ONLINE BOOKS SHOPPING 6 TH SEM BCA 2022/23

<input type="submit" class="btn btn-primary" name="save_change"


value="Save Changes">
</form>
<br/><br/>
<a href="checkout.php" class="btn btn-primary">Go To Checkout</a>
<a href="books.php" class="btn btn-primary">Continue Shopping</a>
<?php
} else {
echo "<p class=\"text-warning\">Your cart is empty! Please make sure
you add some books in it!</p>";
}
if(isset($conn)){ mysqli_close($conn); }
require_once "./template/footer.php";
?>

Checkout.php

<?php
// the shopping cart needs sessions, to start one
/*
Array of session(
cart => array (
book_isbn (get from $_GET['book_isbn']) => number of
books
),
items => 0,
total_price => '0.00'
)
*/
session_start();
require_once "./functions/database_functions.php";
// print out header here
$title = "Checking out";
require "./template/header.php";
37
ONLINE BOOKS SHOPPING 6 TH SEM BCA 2022/23

if(isset($_SESSION['cart']) && (array_count_values($_SESSION['cart']))){


?>
<table class="table">
<tr>
<th>Item</th>
<th>Price</th>
<th>Quantity</th>
<th>Total</th>
</tr>
<?php
foreach($_SESSION['cart'] as $isbn => $qty){
$conn = db_connect();
$book =
mysqli_fetch_assoc(getBookByIsbn($conn, $isbn));
?>
<tr>
<td><?php echo $book['book_title'] . " by " .
$book['book_author']; ?></td>
<td><?php echo "$" . $book['book_price']; ?></td>
<td><?php echo $qty; ?></td>
<td><?php echo "$" . $qty * $book['book_price']; ?></td>
</tr>
<?php } ?>
<tr>
<th>&nbsp;</th>
<th>&nbsp;</th>
<th><?php echo $_SESSION['total_items']; ?></th>
<th><?php echo "$" . $_SESSION['total_price']; ?></th>
</tr>
</table>
<form method="post" action="purchase.php" class="form-horizontal">
<?php if(isset($_SESSION['err']) && $_SESSION['err'] == 1){ ?>
<p class="text-danger">All fields have to be filled</p>
38
ONLINE BOOKS SHOPPING 6 TH SEM BCA 2022/23

<?php } ?>
<div class="form-group">
<label for="name" class="control-label col-md-
4">Name</label>
<div class="col-md-4">
<input type="text" name="name" class="col-md-4"
class="form-control">
</div>
</div>
<div class="form-group">
<label for="address" class="control-label col-md-
4">Address</label>
<div class="col-md-4">
<input type="text" name="address" class="col-md-4"
class="form-control">
</div>
</div>
<div class="form-group">
<label for="city" class="control-label col-md-4">City</label>
<div class="col-md-4">
<input type="text" name="city" class="col-md-4"
class="form-control">
</div>
</div>
<div class="form-group">
<label for="zip_code" class="control-label col-md-4">Zip
Code</label>
<div class="col-md-4">
<input type="text" name="zip_code" class="col-md-4"
class="form-control">
</div>
</div>
<div class="form-group">
<label for="country" class="control-label col-md-
4">Country</label>
39
ONLINE BOOKS SHOPPING 6 TH SEM BCA 2022/23

<div class="col-md-4">
<input type="text" name="country" class="col-md-4"
class="form-control">
</div>
</div>
<div class="form-group">
<input type="submit" name="submit" value="Purchase"
class="btn btn-primary">
</div>
</form>
<p class="lead">Please press Purchase to confirm your purchase, or
Continue Shopping to add or remove items.</p>
<?php
} else {
echo "<p class=\"text-warning\">Your cart is empty! Please make sure
you add some books in it!</p>";
}
if(isset($conn)){ mysqli_close($conn); }
require_once "./template/footer.php";
?>

Contact.php

<?php
$title = "Contact";
require_once "./template/header.php";
?>
<div class="row">
<div class="col-md-3"></div>
<div class="col-md-6 text-center">
<form class="form-horizontal">
<fieldset>
<legend>Contact</legend>
<p class="lead">I’d love to hear from you! Complete
40
ONLINE BOOKS SHOPPING 6 TH SEM BCA 2022/23

the form to send me an email.</p>


<div class="form-group">
<label for="inputName" class="col-lg-2 control-
label">Name</label>
<div class="col-lg-10">
<input type="text" class="form-control"
id="inputName" placeholder="Name">
</div>
</div>
<div class="form-group">
<label for="inputEmail" class="col-lg-2 control-label">Email</label>
<div class="col-lg-10">
<input type="text" class="form-control"
id="inputEmail" placeholder="Email">
</div>
</div>
<div class="form-group">
<label for="textArea" class="col-lg-2 control-
label">Textarea</label>
<div class="col-lg-10">
<textarea class="form-control" rows="3"
id="textArea"></textarea>
<span class="help-block">A longer block of help
text that breaks onto a new line and may extend beyond one line.</span>
</div>
</div>
<div class="form-group">
<div class="col-lg-10 col-lg-offset-2">
<button type="reset" class="btn btn-
default">Cancel</button>
<button type="submit" class="btn btn-
primary">Submit</button>
</div>
</div>
</fieldset>
41
ONLINE BOOKS SHOPPING 6 TH SEM BCA 2022/23

</form>
</div>
<div class="col-md-3"></div>
</div>
<?php
require_once "./template/footer.php";
?>

Edit books.php

<?php
// if save change happen
if(!isset($_POST['save_change'])){
echo "Something wrong!";
exit;
}

$isbn = trim($_POST['isbn']);
$title = trim($_POST['title']);
$author = trim($_POST['author']);
$descr = trim($_POST['descr']);
$price = floatval(trim($_POST['price']));
$publisher = trim($_POST['publisher']);

if(isset($_FILES['image']) && $_FILES['image']['name'] != ""){


$image = $_FILES['image']['name'];
$directory_self = str_replace(basename($_SERVER['PHP_SELF']), '',
$_SERVER['PHP_SELF']);
$uploadDirectory = $_SERVER['DOCUMENT_ROOT'] .
$directory_self . "bootstrap/img/";
$uploadDirectory .= $image;
move_uploaded_file($_FILES['image']['tmp_name'],
$uploadDirectory);
}
42
ONLINE BOOKS SHOPPING 6 TH SEM BCA 2022/23

require_once("./functions/database_functions.php");
$conn = db_connect();

// if publisher is not in db, create new


$findPub = "SELECT * FROM publisher WHERE publisher_name =
'$publisher'";
$findResult = mysqli_query($conn, $findPub);
if(!$findResult){
// insert into publisher table and return id
$insertPub = "INSERT INTO publisher(publisher_name) VALUES
('$publisher')";
$insertResult = mysqli_query($conn, $insertPub);
if(!$insertResult){
echo "Can't add new publisher " . mysqli_error($conn);
exit;
}
}

$query = "UPDATE books SET


book_title = '$title',
book_author = '$author',
book_descr = '$descr',
book_price = '$price'";
if(isset($image)){
$query .= ", book_image='$image' WHERE book_isbn = '$isbn'";
} else {
$query .= " WHERE book_isbn = '$isbn'";
}
// two cases for fie , if file submit is on => change a lot
$result = mysqli_query($conn, $query);
if(!$result){
echo "Can't update data " . mysqli_error($conn);
exit;
43
ONLINE BOOKS SHOPPING 6 TH SEM BCA 2022/23

} else {
header("Location: admin_edit.php?bookisbn=$isbn");
}
?>

Index.php

<?php
session_start();
$count = 0;
// connecto database

$title = "Index";
require_once "./template/header.php";
require_once "./functions/database_functions.php";
$conn = db_connect();
$row = select4LatestBook($conn);
?>
<!-- Example row of columns -->
<p class="lead text-center text-muted">Latest books</p>
<div class="row">
<?php foreach($row as $book) { ?>
<div class="col-md-3">
<a href="book.php?bookisbn=<?php echo $book['book_isbn']; ?>">
<img class="img-responsive img-thumbnail" src="./bootstrap/img/<?php
echo $book['book_image']; ?>">
</a>
</div>
<?php } ?>
</div>
<?php
if(isset($conn)) {mysqli_close($conn);}
require_once "./template/footer.php";

44
ONLINE BOOKS SHOPPING 6 TH SEM BCA 2022/23

?>

Publisher.php

<?php
session_start();
require_once "./functions/database_functions.php";
$conn = db_connect();

$query = "SELECT * FROM publisher ORDER BY publisherid";


$result = mysqli_query($conn, $query);
if(!$result){
echo "Can't retrieve data " . mysqli_error($conn);
exit;
}
if(mysqli_num_rows($result) == 0){
echo "Empty publisher ! Something wrong! check again";
exit;
}

$title = "List Of Publishers";


require "./template/header.php";
?>
<p class="lead">List of Publisher</p>
<ul>
<?php
while($row = mysqli_fetch_assoc($result)){
$count = 0;
$query = "SELECT publisherid FROM books";
$result2 = mysqli_query($conn, $query);
if(!$result2){
echo "Can't retrieve data " . mysqli_error($conn);
exit;

45
ONLINE BOOKS SHOPPING 6 TH SEM BCA 2022/23

}
while ($pubInBook = mysqli_fetch_assoc($result2)){
if($pubInBook['publisherid'] == $row['publisherid']){
$count++;
}
}
?>
<li>
<span class="badge"><?php echo $count; ?></span>
<a href="bookPerPub.php?pubid=<?php echo $row['publisherid'];
?>"><?php echo $row['publisher_name']; ?></a>
</li>
<?php } ?>
<li>
<a href="books.php">List full of books</a>
</li>
</ul>
<?php
mysqli_close($conn);
require "./template/footer.php";
?>

Purchase.php

}
}
require_once "./functions/database_functions.php";
// print out header here
$title = "Purchase";
require "./template/header.php";
// connect database
if(isset($_SESSION['cart']) && (array_count_values($_SESSION['cart']))){
?>

46
ONLINE BOOKS SHOPPING 6 TH SEM BCA 2022/23

<table class="table">
<tr>
<th>Item</th>
<th>Price</th>
<th>Quantity</th>
<th>Total</th>
</tr>
<?php
foreach($_SESSION['cart'] as $isbn => $qty){
$conn = db_connect();
$book =
mysqli_fetch_assoc(getBookByIsbn($conn, $isbn));
?>
<tr>
<td><?php echo $book['book_title'] . " by " .
$book['book_author']; ?></td>
<td><?php echo "$" . $book['book_price']; ?></td>
<td><?php echo $qty; ?></td>
<td><?php echo "$" . $qty * $book['book_price']; ?></td>
</tr>
<?php } ?>
<tr>
<th>&nbsp;</th>
<th>&nbsp;</th>
<th><?php echo $_SESSION['total_items']; ?></th>
<th><?php echo "$" . $_SESSION['total_price']; ?></th>
</tr>
<tr>
<td>Shipping</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>20.00</td>
</tr>
<tr>
47
ONLINE BOOKS SHOPPING 6 TH SEM BCA 2022/23

<th>Total Including Shipping</th>


<th>&nbsp;</th>
<th>&nbsp;</th>
<th><?php echo "$" . ($_SESSION['total_price'] + 20); ?></th>
</tr>
</table>
<form method="post" action="process.php" class="form-horizontal">
<?php if(isset($_SESSION['err']) && $_SESSION['err'] == 1){ ?>
<p class="text-danger">All fields have to be filled</p>
<?php } ?>
<div class="form-group">
<label for="card_type" class="col-lg-2 control-label">Type</label>
<div class="col-lg-10">
<select class="form-control" name="card_type">
<option value="VISA">VISA</option>
<option value="MasterCard">MasterCard</option>
<option value="American Express">American Express</option>
</select>
</div>
</div>
<div class="form-group">
<label for="card_number" class="col-lg-2 control-label">Number</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="card_number">
</div>
</div>
<div class="form-group">
<label for="card_PID" class="col-lg-2 control-label">PID</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="card_PID">
</div>
</div>
<div class="form-group">

48
ONLINE BOOKS SHOPPING 6 TH SEM BCA 2022/23

<label for="card_expire" class="col-lg-2 control-label">Expiry


Date</label>
<div class="col-lg-10">
<input type="date" name="card_expire" class="form-control">
</div>
</div>
<div class="form-group">
<label for="card_owner" class="col-lg-2 control-label">Name</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="card_owner">
</div>
</div>
<div class="form-group">
<div class="col-lg-10 col-lg-offset-2">
<button type="reset" class="btn btn-default">Cancel</button>
<button type="submit" class="btn btn-primary">Purchase</button>
</div>
</div>
</form>
<p class="lead">Please press Purchase to confirm your purchase, or
Continue Shopping to add or remove items.</p>
<?php
} else {
echo "<p class=\"text-warning\">Your cart is empty! Please make sure
you add some books in it!</p>";
}
if(isset($conn)){ mysqli_close($conn); }
require_once "./template/footer.php";
?>

49
ONLINE BOOKS SHOPPING 6 TH SEM BCA 2022/23

Testing and implementation

Testing is critical element of software quality assurance and represents the


ultimate review of specification, design and coding. It is unusual for the
organization to spent 30 or 40 percent of total project effort on testing.

Testing presents the software an interesting anomaly for the software


engineer. The engineer creates the series of test cases that are intended to
demolish the software that has been built. In fact, testing us one-step in the
software engineering process that could be viewed as destructive rather than
constructive.

Testing Objectives

The following are the objectives for the testing.

 Testing is a process of executing a program with the intent of finding an


error.

 A good test case is one that has a high probability of finding an as-yet
undiscovered error.

 A successful test is one that uncovers as-set undiscovered error.

Limitations and Future Development

There are some limitations for the current system to which solutions can be
provided as a future development:

1. The system is not configured for multi- users at this time. The concept
50
ONLINE BOOKS SHOPPING 6 TH SEM BCA 2022/23

of transaction can be used to achieve this.


2. The Website is not accessible to everyone. It can be deployed on a
web server so that everybody who is connected to the Internet can use
it.
3. Credit Card validation is not done. Third party proprietary software
can be used for validation check.

As for other future developments, the following can be done:

1. The Administrator of the web site can be given more functionality,


like looking at a specific customer’s profile, the books that have to
be reordered, etc.
2. Multiple Shopping carts can be allowed.

51
ONLINE BOOKS SHOPPING 6 TH SEM BCA 2022/23

13.0. Conclusion

The Internet has become a major resource in modern business, thus electronic
shopping has gained significance not only from the entrepreneur’s but also from
the customer’s point of view. For the entrepreneur, electronic shopping generates
new business opportunities and for the customer, it makes comparative shopping
possible. As per a survey, most consumers of online stores are impulsive and
usually make a decision to stay on a site within the first few seconds. “Website
design is like a shop interior. If the shop looks poor or like hundreds of other shops
the customer is most likely to skip to the other site”. Hence we have designed the
project to provide the user with easy navigation, retrieval of data and necessary
feedback as much as possible. In this project, the user is provided with an e-
commerce web site that can be used to buy books online. To implement this as a
web application we used PHP as the Technology. PHP (XAMPP) has several
advantages such as enhanced performance, scalability, built- in security and
simplicity. To build any web application using PHP we need a programming
language such as JAVA, HTML # and so on. JAVA SCRIPT was the language
used to build this application. PHP uses MySQL server to interact with the
database as it provides in-memory caching that eliminates the need to contact the
database server frequently and it can easily deploy and maintain an PHP
application. MySQL was used as back-end database since it is one of the most
popular open source databases, and it provides fast data access, easy installation
and simplicity.
A good shopping cart design must be accompanied with user-friendly shopping
cart application logic. It should be convenient for the customer to view the contents
of their cart and to be able to remove or add items to their cart. The shopping cart
application described in this project provides a number of features that are
designed to make the customer more comfortable. This project helps in
understanding the creation of an interactive web page and the technologies used to
implement it. The design of the project which includes Data Model and Process
Model illustrates how the database is built with different tables, how the data is
accessed and processed from the tables. The building of the project has given me a
precise knowledge about how PHP is used to develop a website, how it connects to
the database to access the data and how the data and web pages are modified to
provide the user with a shopping cart application.

52
ONLINE BOOKS SHOPPING 6 TH SEM BCA 2022/23

Links & Source


 https://en.wikipedia.org/wiki/Bookselling
 https://www.techopedia.com/definition/23889/web-development
 http://php.net/manual/en/intro-whatis.php
 https://www.mysql.com/about/
 https://en.wikipedia.org/wiki/MySQL
 https://www.w3schools.com/php/php_mysql_intro.asp

53

You might also like