You are on page 1of 73

Karnataka College of Management and Science

NAAC Accredited

PROJECT REPORT

ON

“Online Book Store”

SUBMITTED BY THE REQUIREMENT FOR THE AWARD OF THE

DEGREE OF

BACHELOR OF COMPUTER APPLICATIONS (BCA)


BANGALORE UNIVERSITY

SUBMITTED BY: REG NO:

UNDER THE ESTEEMED GUIDANCE OF

Mrs.S.Vijaya Rani, MCA,M.Phil,(Ph.D)


Karnataka College of Management and Science

Project Report on

“Online Book Store ”

Submitted By: -------------------------------------------------------

Submitted To:

Department of Computer Applications,KCMS


Abstract

This paper presents the research and findings of a student registration system at Methodist
University College Ghana. It was found out that students have to be physically present on their
campuses to do registration for the semester, after the payment of fees. With the numerous
alternatives in technological choices, this research sort to find out which alternative would help
eliminate the current difficulties students go through in order to register for the semester. This
paper analyzed this existing system using the waterfall model leading to a design and
development of an online registration system which does not require the physical presence of
students on campus but to remotely register.

Keywords: registration system, development

1 Introduction

In this technological era of education and doing business, information is considered to be an


important asset for any academic institution. The availability of student data and feedback can
help an educational institution to align its business processes according to the needs of its
students and stakeholders. The effective management of these data can help institutions reach out
directly to their students and stakeholders and also to streamline its activities.

Commitment towards the success of students of higher education can be achieved through
innovations such as flexible scheduling, continuous enrolment, a university-wide academic social
network, online classes, a digital library, computer simulations and online student registration as
well. This innovative approach helps pioneer many of the conveniences of students - a kind of
education that is research-proven to be just as effective as conventional instruction.

At Methodist University College Ghana, just like the other universities, students are enrolled to
pursue a 4-year academic degree program. Some are also enrolled at either 2 nd or 3rd year for a
top-up leading to the award of a degree. Students must pass and obtain the minimum university
admission requirements of the SSSCE/WASSCE exams in order to qualify for admission. Other
admission requirements include a Post-Secondary Diploma or Professional Certifications from a
recognized institution or HND.

An enrolled student is expected to register and pay either full or part of the school fees before he
can take courses every semester. In most cases, enrolling and having to register every semester
involves some manual processes which delay processes for both the university and more
especially the students.
Student registration is done by students mostly at a registration center. Students have to move
physically to campus:
Dansoman, Tema or Wenchi to complete the registration process. In some cases, students
move from Tema to Dansoman campus, about 45 km apart to complete the registration process.
The following are the problems inherent with the current system.

• Insufficient online utilities in handling student registration.


• Inability of students to remotely register and access documents like transcript.

• Students take too much time in processing their registration and worse, this can only be
done with their physical presence on campus.

It is in this regard that this research looks at the student registration system at Methodist
University College Ghana in order to design and develop an online student registration system.
2.1 Introduction

In a rapidly emerging world of technological advancement and innovations, computer has


become a way of life and a driving force of modern industry and businesses (studymode.com). It
has become one of the most significant tools for more productive operations and accurate results
(Kramer et al, 2007).

Web development can include a web design, web content development, client liaison, client-
server-side scripting, web server and network security configuration, and e-commerce
development (Rajapakse, 2012). It can range from developing the simplest static single page of
plain text to the most complex web-based internet applications, electronic businesses or social
network services (Rajapakse, 2012). Many organizations and institutions increase their
investment in web-technology and online systems. The scope of web-based applications has
grown enormously and has moved to become a platform that can support all facet of
organizational work (Isakowitz et al., 1998).

For this reason, engineers and IT specialists strive and are still vigilant in combining web
development to the practical application of scientific investigations and research in developing
systems that can support the core business processes of institutions (studymode.com).

2.2 The Role of Information Systems in an Institution

An institution without an information system will have no track record of its performance history
or its present status and will be unable to forecast the future of its business. According to
O’Brien & Marakas (2007), the fundamental roles of an information system are to support
business processes, support decision-making by its employees and support strategies for
competitive advantage. Laudon & Laudon (2007) point out that the role of information systems
is to help institutions obtain operational excellence to improve the efficiency of their operations
in order to achieve higher profitability. According to O’Brien & Marakas (2007), information
systems are a major functional area of business that is equally as important to business success as
the functions of accounting, finance and human resources management.

2.3 Background Studies of Previous Registration Systems

“The internet has opened many possibilities for the classroom instruction but it can also be a
barrier to teaching as well” (Bugeja, 2006). The new innovative technologies provide
opportunities to improve learning and create a more exciting and motivating environment
(Connors, 2007).
According to a case study by Ralph, Buskirk, and Schmidt (2007) regarding the use of online
projects, students in favor of online projects indicated that the accessibility to the professor for
fast and easy feedback was a great asset. Furthermore, the study revealed that when
implementing technology, students were concerned with the expense of the technology, the
necessity for internet access, and the reliability of the technology. Research on student
perceptions and satisfaction with online registration of courses provide insights to student
reactions and satisfaction with implementation of an online registration system. Hale (2007)
found that student satisfaction surveys reveal that the most important reason for taking an online
registration is its convenience.

The “widespread availability of computers and the Internet provide considerable enrichment in
terms of variety of material and formats for presentation over what was possible with the old
correspondence courses” (Walker and Kelly, 2007). The Chronicle for Higher Education (2007)
reported that a university stated that they use electronic education to add on to their curriculum,
not as the main basis. This lends to the implementation of an online service such as a student
registration system to register for courses, take lessons via distant learning and under an exam.

3 Methodology

The data collection instruments used were, Interviews: this was used to solicit information from
students, the faculty officers and staff of the programming unit of MUCG and also, some of the
university’s registration records were examined. DFD, Use Case Diagrams and Sequence
diagrams where used to model the existing and proposed system. PHP and MySQL were the
tools used to develop the system.

3.1 Analysis of the Current System

According to Temple (2006), the registration process involves step-by-step interdependent


actions that work together to produce outcomes.
3.1.1 Context Diagram of the Current System

Student

Faculty Officer

Studen
t

Detail
s
Student
Details
Enquir
y/
Registration
Complai Registratio
nt Student n
Details
Details Complaints Details

Registration
System

Handled complaints

Fig. 1: Context Diagram of the Current System


In the current system, a student having to register must first come to the school to go through the
processes. Students are expected to deposit cheques or bankers draft at the cash office before a
slip is printed out to take to the Faculty Officer. At the bank, students queue for long hours as
well as at the registration centers (faculties). During the registration, each student is asked to
provide some basic personal information such as his/her index number to begin the registration
process. The student’s personal information obtained is fed into the registration system, the
Faculty/Registration Officer then checks to see if details given by the student are correct and
then there is selection of courses. The student is then handed the registration printout and made
to append his signature in a book to confirm his registration. The printout shows the date and
time of registration, courses registered with the number of credit hours allocated for each course.
The student must check the courses registered to be sure those are the ones he has to offer for the
semester.

This is done in the first two weeks of reopening, as a registration center is opened. After that
period, students have to go to the office of the Faculty Officer to be registered. A Student who
does not meet the deadline attracts a penalty depending on the number of days after the deadline,
especially continuing students. For the fresh students, there is a time frame after which you are
not allowed to register.

The current system requires the physical presence of the student on campus. The student goes to
the registration center to continue the registration process after payment of the required fees.
Fresh students go to the programming unit to have their bio data checked and passport
photographs taken before they can go to their respective faculty offices to be registered after two
weeks.
3.1.2 Flowchart of the Current System

Start
Pay fees

Validate payment

Go to Registration Center

New No

Student?
Yes
Go to Programming Unit

Complete Registration

Terminate

Fig. 2: Flowchart of Current System

3.1.3 The Current Payment System

The current system accepts payment in cheques and bankers draft from all banks in the country.
However this may take one or two forms reflecting the category of students who are admitted
into the school. The school admits two categories of students: Foreign and Ghanaian students.
The major services charged at the University include: Admission Fees, Registration Fees,
Library Services, Computer User Fees and SRC dues, etc.
3.2 The Proposed System

To obtain information about the student registration system, it was necessary to interview
students, the responsible staff like the Faculty Officers and staff of the Programming Unit.
Getting to know how the University conducts its registration helped flag any apparently unusual
aspects. Understanding the concerns of students helped to incorporate them in the development
of the proposed system.

With the gathered data, a use case diagram was developed to incorporate the actors of the
system. Students and faculty officers play a critical role as actors. It is conceivable that other
actors may be added in subsequent iterations. Fig. 3 shows the use case diagram of the proposed
system.

IJRIT International Journal of Research in Information Technology, Volume 2, Issue 9,


September 2014, Pg. 321-333

Student

Registration

Manage

Student Accounts Administrator

System Login

Fig. 3: Use Case Diagram of Proposed System.


At the start of each registration day, each front-end system is connected by a TCP. One process
for each connected front-end is created on the system; this process is responsible for interpreting
the messages from the front-end and translating them into corresponding operations on the
registration database. In order to balance the load on these systems, each user is asked to connect
to a client system. If that system is unavailable, then the user is asked to try a particular backup
system from among other machines.

Prior to the start of the registration, the database is pre-loaded with data pertaining to existing
students. Under some circumstances, it is expected that a small number of new student records
would have to be created during the registration process.

3.2.1 Network Architecture the Proposed System

Figure 3.6 depicts the design of the network architecture of the proposed system. This design
serves as a communication between the various components of the system network and how it is
implemented. It is a framework for the specification of the network's physical components and
their functional organization and configuration, its operational principles and procedures.

Administrat
Data Repository or

Serve
r

Internet
4 Design of the Proposed System

There is no more need for opening a registration center to do the registration. A student can
remotely register from any location.

Context Diagram of the Proposed System

Faculty Officer

Registration
Report Upload/Update

details
Administrator

Registration MUCG portal

Receipt

Registration Report

Student
Registration Details
Fig. 5: Context Diagram of the Proposed System
Get
Student
Faculty Officer
Pay Fees

Update
Register for the

semester

Get Registration
Administrator

Receipt Upload Files

Fig. 6: Exploded Use Case Diagram of the Proposed System


4.1 Registration Subsystem

This is the main and the most important subsystem of the web portal. The system can manage
the registration activities in real time thereby solving the registration problems inherent with
the current system.
A student after making payment of fees at the bank is given a receipt with a code. He needs
this code when doing the registration to validate his payment. Students are able to register on
their own anywhere and not having to come to campus if this new system is implemented.
This eliminates the long queues and pressures of the old system.
The registration process is a vital component of the system, and must be transparent to the
end users. The student gets two reports as feedback; a confirmation of registration and a
confirmation of payment.

Registration System
Student

Open
Database

Registration

Page

EnterData

CheckDuplication
CalculatedFees
Update Data
Confirm Print
Report Update

Fig. 7: Student Registration’s Sequence Diagram


What goes inside is a set of operations depicted in Fig. 7, showing a Sequence Diagram of the
Registration Process. The Sequence Diagram shows system objects and how they interact
with each other and the order in which these interactions occur (IBM, UML’s Sequence
Diagram, 2014).

4.2 Repository Subsystem

Looking at the System's sequence diagram, it's clear that there are three means of
communication between system users and the registration system. The first communication
method is by using the reporting subsystem which issues different types of reports as
demanded. Another method is by updates done by system's administrator, and viewed by
Faculty Officers. The last method is by using the System Repository. It is a tool that enables
students to download files necessary for managing their school activities. Such files include
the payment history, bills for next semester, course registration confirmation and program of
study.

Users of the system may link to the latest regulations and news issued by MUCG authorities
and can also download various files. Files are uploaded by a user with administrator
privileges having different formats: PDF and DOC.

4.3 System Features

The system utilizes codeigniter framework which makes it necessary to build system
components and objects. This system was developed using PHP as the webpage design tool
in combination with HTML as the technology that provides the necessary coding behind the
web pages. The application connects to MySQL Server database, which plays the role of the
RDBMS associated with the application. Users of the system can run the application through
their internet browsers, such as IE v6 or higher.

4.4 Database Design


The proposed system is a 3-Tier web-based system meaning a Client/Server Architecture in
which the user interface, functional process logic (business rules), computer data storage, and
data access are developed and maintained as independent modules, most often in different
platforms. Fig. 8 shows a 3-Tier Architecture design.
4.5 The Database Layer
The proposed system's database is developed using MySQL Server. This layer provides high
connectivity and availability. It provides system developers with the ability to manage and
administer databases easily, especially using the Graphical User Interface (GUI) of its
Management Studio. In addition, it enables developers to either create their own stored
procedures or use built-in ones.
Using MySQL Server as a RDBMS gives the user the ability to create server-side cursors to
iterate programmatically through different table records and manipulate them row by row. At
development time, developers may need to process resulting records at the server without the
need to use another programming language, i.e. by means of the built-in functionality of the
RDBMS.
4.6 The Application Layer
As shown in Fig. 8, the Application Layer contains the User Interface (UI), Business Rules,
and the Data-Access Components. In this system, PHP is used to provide data access to the
MySQL Server 2008. All the accessing data codes and business rules implementation were
developed using PHP framework codeigniter; the code was written in files, each contains a
class or more to handle the operations of web forms. Internet Information Services (IIS) v5 or
later must run on the Application Server.
4.7 The Client Layer
The simplest client must have a PC, preferably running Windows XP with Internet Explorer
(IE) installed to enable the client to browse the website over the Internet. As a web-based
application, all processing is done on behalf of the users' computers on the server hosting the
system. So, other operating systems such as Linux, UNIX, MacOS, etc. would be acceptable
on client machines.

Fig. 8: 3-Tier Architecture design


5 System Development
The system was developed successfully resulting in the following below; a brief of the entire
solution.
1.3.1 HARDWARE SPECIFICATION

CPU : Intel Core i3

RAM : 32MB

Hard Disk : 5 GB

Monitor :16LG

Mouse : Logitech mouse

Keyboard : 104 Keys

Mother Board : Intel

Speed : 3.3 GHZ


1.3.2 SOFTWARE SPECIFICATION

Project Name Online Course Registration

Language Used PHP5.6, PHP7.x

Database MySQL 5.x

User Interface Design HTML, AJAX,JQUERY,JAVASCRIPT

Web Browser Mozilla, Google Chrome, IE8, OPERA

Software XAMPP / Wamp / Mamp/ Lamp (anyone)

1.4 SOFTWARE FEATURES


Features of PHP

The main features of php is; it is open source scripting language so you can free download
this and use. PHP is a server site scripting language. It is open source scripting language.
It is widely used all over the world. It is faster than other scripting language. Some
important features of php are given below;

Features of php

It is most popular and frequently used world wide scripting language, the main reason of
popularity is; It is open source and very simple.

 Simple

 Faster

 Interpreted

 Open Source

 Case Sensitive

 Simplicity

 Efficiency

 Platform Independent

 Security

 Flexibility

 Familiarity

 Error Reporting

 Loosely Typed Language

 Real-Time Access Monitoring


Simple

It is very simple and easy to use, compare to other scripting language it is very simple and
easy, this is widely used all over the world.

Interpreted

It is an interpreted language, i.e. there is no need for compilation.

Faster

It is faster than other scripting language e.g. asp and jsp.

Open Source

Open source means you no need to pay for use php, you can free download and use.

Platform Independent

PHP code will be run on every platform, Linux, Unix, Mac OS X, Windows.

Case Sensitive

PHP is case sensitive scripting language at time of variable declaration. In PHP, all
keywords (e.g. if, else, while, echo, etc.), classes, functions, and user-defined functions
are NOT case-sensitive.

Error Reporting

PHP have some predefined error reporting constants to generate a warning or error notice.

Real-Time Access Monitoring

PHP provides access logging by creating the summary of recent accesses for the user.

Loosely Typed Language

PHP supports variable usage without declaring its data type. It will be taken at the time of
the execution based on the type of data it has on its value.
XAMPP is a software distribution which provides the Apache web server, MySQL database
(actually MariaDB), Php and Perl (as command-line executables and Apache modules) all in
one package. It is available for Windows, MAC and Linux systems. No configuration is
necessary to integrate Php with MySQL.

It is a great fit for this course and provides a relatively painless installation and way to
manage the configuration changes. Also provided is PhpMyadmin which gives a GUI tool for
managing your MySQL databases.

I would highly recommend installing this for Windows or MAC. It doesn't exclude you from
other competing software installations, it just gives an easy way to get going. For Ubuntu
Linux systems, I still would recommend installing Apache/MySQL/Php/PhpMyadmin
through Ubuntu packages.

The XAMPP download site which I use is:

https://www.apachefriends.org/

The installation I'm describing uses Php 7.3.

For MAC, use the non-vm version

For the MAC, we use the non-vm version which you can find in the Downloads menu link
of the site. In particular avoid the version with "-vm" as part of the file name.

Windows

The installation file I used is:

xampp-win32-7.3.0-0-VC15-installer.exe

Install in the usual way. It gives some notification messages for which you can just click OK.
Close whatever installation brings upon completion. It installs into

C:\xampp
At some point the Windows Firewall may invoke notifications; just click Allow access and
then Finish.

Run XAMPP Control Panel as administrator

What you want to run is the XAMPP Control Panel found under XAMPP in the Start menu.
Right-click and run this as administrator.
Start both MySQL and Apache (unless you have an alternative Apache installation). I do not
recommend messing with the Modules service column. When you start MySQL, you should
see it running on port 3306. The Apache service gives you access to the Admin buttons next
to the services. For Apache Admin, you get:

http://localhost/dashboard

For MySQL Admin you get PhpMyadmin:

http://localhost/phpmyadmin

The MySQL clients

The MySQL Client executables are located in the directory

C:\xampp\mysql\bin
The most important one is the client program mysql.exe. From a command shell you can run:

> C:\xampp\mysql\bin\mysql (with or without the .exe extension)


MariaDB[(none)]>
MariaDB[(none)]> quit
This accesses the MariaDB database as the empty (or default) user with empty password.
You can go into a specific database, say test, by doing:

mysql> use test


MariaDB[(test)]>
This test database already exists in the XAMPP MariaDB installation. It is accessible by the
empty user. You can also go directly into the test database from the command line by:

> C:\xampp\mysql\bin\mysql test


MariaDB[(test)]>
You can also go in as an unknown user, e.g.:

> C:\xampp\mysql\bin\mysql -u guest test


What's happening here is that the unknown user is getting replaced by the empty user.

If you want to create other databases, or users, or alter passwords, you have to be
the root user. To do so:

> C:\xampp\mysql\bin\mysql -u root


The XAMPP installation also sets up the empty password to the root user.
Easy access to mysql

Although it is probably OK to use mysql as:

C:\xampp\mysql\bin\mysql
You might want to make it usable simply as mysql. Here are two ways to do so.

1. The best solution is to put the directory into your PATH. Start from Control Panel ⇾
System and Security and access:
System ⇾ Advanced System Settings ⇾ Advanced ⇾ Environment Variables
Find the Path variable in the System Variables. Select it and click Edit. It's best
to prepend the new Path component with this addition:
C:\xampp\mysql\bin;
The Home button on a Microsoft keyboard is a good way to get to the beginning of
the Path expression. Alternatively, you can append the new Path component as:

;C:\xampp\mysql\bin
Then "OK" your way out.

2. Another way is to make a convenience batch executable in the directory where your
shell opens up into (it should be your home directory). Go to your home
directory C:\Users\YOUR_LOGIN (or wherever your shell opens into) and create the
file
3. mysql.bat
Make sure file extensions are shown. Create an empty text file (New Text
Document.txt) and rename the whole file to mysql.bat (Windows will complain!).
Make the contents be:

@echo off
C:\xampp\mysql\bin\mysql %*

With either of these in place, start a new command shell and test it by running

> mysql
CODING
INDEX.PHP

<?php
session_start();
include "dbconnect.php";

if (isset($_GET['Message'])) {
print '<script type="text/javascript">
alert("' . $_GET['Message'] . '");
</script>';
}

if (isset($_GET['response'])) {
print '<script type="text/javascript">
alert("' . $_GET['response'] . '");
</script>';
}

if(isset($_POST['submit']))
{
if($_POST['submit']=="login")
{
$username=$_POST['login_username'];
$password=$_POST['login_password'];
$query = "SELECT * from users where UserName ='$username' AND
Password='$password'";
$result = mysqli_query($con,$query)or die(mysql_error());
if(mysqli_num_rows($result) > 0)
{
$row = mysqli_fetch_assoc($result);
$_SESSION['user']=$row['UserName'];
print'
<script type="text/javascript">alert("successfully logged in!!!");</script>
';
}
else
{ print'
<script type="text/javascript">alert("Incorrect Username Or Password!!");</script>
';
}
}
else if($_POST['submit']=="register")
{
$username=$_POST['register_username'];
$password=$_POST['register_password'];
$query="select * from users where UserName = '$username'";
$result=mysqli_query($con,$query) or die(mysql_error);
if(mysqli_num_rows($result)>0)
{
print'
<script type="text/javascript">alert("username is taken");</script>
';

}
else
{
$query ="INSERT INTO users VALUES ('$username','$password')";
$result=mysqli_query($con,$query);
print'
<script type="text/javascript">
alert("Successfully Registered!!!");
</script>
';
}
}
}
?>

<!DOCTYPE html>
<html lang="en">
<head>

<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Books">
<meta name="author" content="Shivangi Gupta">
<title>Online Bookstore</title>
<!-- Bootstrap -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/my.css" rel="stylesheet">
<style>
.modal-header {background:#D67B22;color:#fff;font-weight:800;}
.modal-body{font-weight:800;}
.modal-body ul{list-style:none;}
.modal .btn {background:#D67B22;color:#fff;}
.modal a{color:#D67B22;}
.modal-backdrop {position:inherit !important;}
#login_button,#register_button{background:none;color:#D67B22!important;}
#query_button {position:fixed;right:0px;bottom:0px;padding:10px 80px;
background-color:#D67B22;color:#fff;border-color:#f05f40;border-
radius:2px;}
@media(max-width:767px){
#query_button {padding: 5px 20px;}
}
</style>
</head>
<body>
<nav class="navbar navbar-default navbar-fixed-top navbar-inverse">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-
target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#" style="padding: 1px;"><img class="img-
responsive" alt="Brand" src="img/logo.jpg" style="width: 147px;margin: 0px;"></a>
</div>

<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<?php
if(!isset($_SESSION['user']))
{
echo'
<li>
<button type="button" id="login_button" class="btn btn-lg" data-toggle="modal"
data-target="#login">Login</button>
<div id="login" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-
dismiss="modal">&times;</button>
<h4 class="modal-title text-center">Login Form</h4>
</div>
<div class="modal-body">
<form class="form" role="form" method="post"
action="index.php" accept-charset="UTF-8">
<div class="form-group">
<label class="sr-only" for="username">Username</label>
<input type="text" name="login_username" class="form-
control" placeholder="Username" required>
</div>
<div class="form-group">
<label class="sr-only" for="password">Password</label>
<input type="password" name="login_password"
class="form-control" placeholder="Password" required>
</div>
<div class="form-group">
<button type="submit" name="submit" value="login"
class="btn btn-block">
Sign in
</button>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-
dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</li>
<li>
<button type="button" id="register_button" class="btn btn-lg" data-toggle="modal"
data-target="#register">Sign Up</button>
<div id="register" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-
dismiss="modal">&times;</button>
<h4 class="modal-title text-center">Member Registration Form</h4>
</div>
<div class="modal-body">
<form class="form" role="form" method="post" action="index.php"
accept-charset="UTF-8">
<div class="form-group">
<label class="sr-only" for="username">Username</label>
<input type="text" name="register_username" class="form-
control" placeholder="Username" required>
</div>
<div class="form-group">
<label class="sr-only" for="password">Password</label>
<input type="password" name="register_password"
class="form-control" placeholder="Password" required>
</div>
<div class="form-group">
<button type="submit" name="submit" value="register"
class="btn btn-block">
Sign Up
</button>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-
dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</li>';
}
else
{ echo' <li> <a href="#" class="btn btn-lg"> Hello ' .$_SESSION['user']. '.</a></li>
<li> <a href="cart.php" class="btn btn-lg"> Cart </a> </li>;
<li> <a href="destroy.php" class="btn btn-lg"> LogOut </a> </li>';

}
?>

</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
<div id="top" >
<div id="searchbox" class="container-fluid" style="width:112%;margin-left:-6%;margin-
right:-6%;">
<div>
<form role="search" method="POST" action="Result.php">
<input type="text" class="form-control" name="keyword"
style="width:80%;margin:20px 10% 20px 10%;" placeholder="Search for a Book , Author
Or Category">
</form>
</div>
</div>

<div class="container-fluid" id="header">


<div class="row">
<div class="col-md-3 col-lg-3" id="category">
<div style="background:#D67B22;color:#fff;font-
weight:800;border:none;padding:15px;"> The Book Shop </div>
<ul>
<li> <a href="Product.php?value=entrance%20exam"> Entrance Exam </a>
</li>
<li> <a href="Product.php?value=Literature%20and%20Fiction"> Literature &
Fiction </a> </li>
<li> <a href="Product.php?value=Academic%20and%20Professional">
Academic & Professional </a> </li>
<li> <a href="Product.php?value=Biographies%20and%20Auto
%20Biographies"> Biographies & Auto Biographies </a> </li>
<li> <a href="Product.php?value=Children%20and%20Teens"> Children &
Teens </a> </li>
<li> <a href="Product.php?value=Regional%20Books"> Regional Books </a>
</li>
<li> <a href="Product.php?value=Business%20and%20Management">
Business & Management </a> </li>
<li> <a href="Product.php?value=Health%20and%20Cooking"> Health and
Cooking </a> </li>

</ul>
</div>
<div class="col-md-6 col-lg-6">
<div id="myCarousel" class="carousel slide carousel-fade" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
<li data-target="#myCarousel" data-slide-to="3"></li>
<li data-target="#myCarousel" data-slide-to="4"></li>
<li data-target="#myCarousel" data-slide-to="5"></li>
</ol>

<!-- Wrapper for slides -->


<div class="carousel-inner" role="listbox">
<div class="item active">
<img class="img-responsive" src="img/carousel/1.jpg">
</div>

<div class="item">
<img class="img-responsive "src="img/carousel/2.jpg">
</div>

<div class="item">
<img class="img-responsive" src="img/carousel/3.jpg">
</div>
<div class="item">
<img class="img-responsive"src="img/carousel/4.jpg">
</div>

<div class="item">
<img class="img-responsive" src="img/carousel/5.jpg">
</div>

<div class="item">
<img class="img-responsive" src="img/carousel/6.jpg">
</div>
</div>
</div>
</div>
<div class="col-md-3 col-lg-3" id="offer">
<a href="Product.php?value=Regional%20Books"> <img class="img-
responsive center-block" src="img/offers/1.png"></a>
<a href="Product.php?value=Health%20and%20Cooking"> <img
class="img-responsive center-block" src="img/offers/2.png"></a>
<a href="Product.php?value=Academic%20and%20Professional"> <img
class="img-responsive center-block" src="img/offers/3.png"></a>
</div>
</div>
</div>
</div>

<div class="container-fluid text-center" id="new">


<div class="row">
<div class="col-sm-6 col-md-3 col-lg-3">
<a href="description.php?ID=NEW-1&category=new">
<div class="book-block">
<div class="tag">New</div>
<div class="tag-side"><img src="img/tag.png"></div>
<img class="book block-center img-responsive" src="img/new/1.jpg">
<hr>
Like A Love Song <br>
Rs 113 &nbsp
<span style="text-decoration:line-through;color:#828282;"> 175 </span>
<span class="label label-warning">35%</span>
</div>
</a>
</div>
<div class="col-sm-6 col-md-3 col-lg-3">
<a href="description.php?ID=NEW-2&category=new">
<div class="book-block">
<div class="tag">New</div>
<div class="tag-side"><img src="img/tag.png"></div>
<img class="block-center img-responsive" src="img/new/2.jpg">
<hr>
General Knowledge 2017 <br>
Rs 68 &nbsp
<span style="text-decoration:line-through;color:#828282;"> 120 </span>
<span class="label label-warning">43%</span>
</div>
</a>
</div>
<div class="col-sm-6 col-md-3 col-lg-3">
<a href="description.php?ID=NEW-3&category=new">
<div class="book-block">
<div class="tag">New</div>
<div class="tag-side"><img src="img/tag.png"></div>
<img class="block-center img-responsive" src="img/new/3.png">
<hr>
Indian Family Bussiness Mantras <br>
Rs 400 &nbsp
<span style="text-decoration:line-through;color:#828282;"> 595 </span>
<span class="label label-warning">33%</span>
</div>
</a>
</div>
<div class="col-sm-6 col-md-3 col-lg-3">
<a href="description.php?ID=NEW-4&category=new">
<div class="book-block">
<div class="tag">New</div>
<div class="tag-side"><img src="img/tag.png"></div>
<img class="block-center img-responsive" src="img/new/4.jpg">
<hr>
Kiran s SSC Mathematics Chapterwise Solutions <br>
Rs 289 &nbsp
<span style="text-decoration:line-through;color:#828282;"> 435 </span>
<span class="label label-warning">33%</span>
</div>
</a>
</div>
</div>
</div>

<div class="container-fluid" id="author">


<h3 style="color:#D67B22;"> POPULAR AUTHORS </h3>
<div class="row">
<div class="col-sm-5 col-md-3 col-lg-3">
<a href="Author.php?value=Durjoy%20Datta"><img class="img-responsive center-
block" src="img/popular-author/0.jpg"></a>
</div>
<div class="col-sm-6 col-md-3 col-lg-3">
<a href="Author.php?value=Chetan%20Bhagat"><img class="img-responsive
center-block" src="img/popular-author/1.jpg"></a>
</div>
<div class="col-sm-6 col-md-3 col-lg-3">
<a href="Author.php?value=Dan%20Brown"><img class="img-responsive center-
block" src="img/popular-author/2.jpg"></a>
</div>
<div class="col-sm-6 col-md-3 col-lg-3">
<a href="Author.php?value=Ravinder%20Singh"><img class="img-responsive
center-block" src="img/popular-author/3.jpg"></a>
</div>
</div>
<div class="row">
<div class="col-sm-5 col-md-3 col-lg-3">
<a href="Author.php?value=Jeffrey%20Archer"><img class="img-responsive
center-block" src="img/popular-author/4.jpg"></a>
</div>
<div class="col-sm-6 col-md-3 col-lg-3">
<a href="Author.php?value=Salman%20Rushdie"><img class="img-responsive
center-block" src="img/popular-author/5.jpg"><a>
</div>
<div class="col-sm-6 col-md-3 col-lg-3">
<a href="Author.php?value=J%20K%20Rowling"><img class="img-responsive
center-block" src="img/popular-author/6.jpg"></a>
</div>
<div class="col-sm-6 col-md-3 col-lg-3">
<a href="Author.php?value=Subrata%20Roy"><img class="img-responsive center-
block" src="img/popular-author/7.jpg"></a>
</div>
</div>
</div>

<footer style="margin-left:-6%;margin-right:-6%;">
<div class="container-fluid">
<div class="row">
<div class="col-sm-1 col-md-1 col-lg-1">
</div>
<div class="col-sm-7 col-md-5 col-lg-5">
<div class="row text-center">
<h2>Let's Get In Touch!</h2>
<hr class="primary">
<p>Still Confused? Give us a call or send us an email and we will get back to
you as soon as possible!</p>
</div>
<div class="row">
<div class="col-md-6 text-center">
<span class="glyphicon glyphicon-earphone"></span>
<p>123-456-6789</p>
</div>
<div class="col-md-6 text-center">
<span class="glyphicon glyphicon-envelope"></span>
<p>BookStore@gmail.com</p>
</div>
</div>
</div>
<div class="hidden-sm-down col-md-2 col-lg-2">
</div>
<div class="col-sm-4 col-md-3 col-lg-3 text-center">
<h2 style="color:#D67B22;">Follow Us At</h2>
<div>
<a href="https://twitter.com/strandbookstore">
<img title="Twitter" alt="Twitter" src="img/social/twitter.png" width="35"
height="35" />
</a>
<a href="https://www.linkedin.com/company/strand-book-store">
<img title="LinkedIn" alt="LinkedIn" src="img/social/linkedin.png"
width="35" height="35" />
</a>
<a href="https://www.facebook.com/strandbookstore/">
<img title="Facebook" alt="Facebook" src="img/social/facebook.png"
width="35" height="35" />
</a>
<a href="https://plus.google.com/111917722383378485041">
<img title="google+" alt="google+" src="img/social/google.jpg" width="35"
height="35" />
</a>
<a href="https://www.pinterest.com/strandbookstore/">
<img title="Pinterest" alt="Pinterest" src="img/social/pinterest.jpg" width="35"
height="35" />
</a>
</div>
</div>
</div>
</div>
</footer>
<div class="container">
<!-- Trigger the modal with a button -->
<button type="button" id="query_button" class="btn btn-lg" data-toggle="modal" data-
target="#query">Ask query</button>
<!-- Modal -->
<div class="modal fade" id="query" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header text-center">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">Ask your query here</h4>
</div>
<div class="modal-body">
<form method="post" action="query.php" class="form" role="form">
<div class="form-group">
<label class="sr-only" for="name">Name</label>
<input type="text" class="form-control" placeholder="Your Name"
name="sender" required>
</div>
<div class="form-group">
<label class="sr-only" for="email">Email</label>
<input type="email" class="form-control" placeholder="abc@gmail.com"
name="senderEmail" required>
</div>
<div class="form-group">
<label class="sr-only" for="query">Message</label>
<textarea class="form-control" rows="5" cols="30" name="message"
placeholder="Your Query" required></textarea>
</div>
<div class="form-group">
<button type="submit" name="submit" value="query" class="btn btn-
block">
Send Query
</button>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-
dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>

<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->


<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="js/bootstrap.min.js"></script>
</body>
</html>
LOGIN.PHP
<?php
include "dbconnect.php";

if(isset($_POST['submit']))
{
if($_POST['submit']=="login")
{
$username=$_POST['login_username'];
$password=$_POST['login_password'];
$query = "SELECT * from users where UserName ='$username' AND
Password='$password'";
$result = mysqli_query($con,$query)or die(mysql_error());
if(mysqli_num_rows($result) > 0)
{
$row = mysqli_fetch_assoc($result);
$_SESSION['user']=$row['UserName'];
header("Location: index.php?login=" . "Successfully Logged In");
}
else
echo "Incorrect username or password";
}
}

?>
PRODUCT.PHP

<?php
session_start();
if(!isset($_SESSION['user']))
header("location: index.php?Message=Login To Continue");
?>

<!DOCTYPE html>
<html lang="en">
<head>

<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Books">
<meta name="author" content="Shivangi Gupta">
<title>Online Bookstore</title>
<!-- Bootstrap -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/my.css" rel="stylesheet">

<style>

#books {margin-bottom:50px;}

@media only screen and (width: 767px) { body{margin-top:150px;}}


#books .row{margin-top:20px;margin-bottom:10px;font-weight:800;}
@media only screen and (max-width: 760px) { #books .row{margin-top:10px;}}
</style>

</head>
<body>

<nav class="navbar navbar-default navbar-fixed-top navbar-inverse">


<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-
target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.php"><img alt="Brand" src="img/logo.jpg"
style="width: 118px;margin-top: -7px;margin-left: -10px;"></a>
</div>

<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<?php
if(isset($_SESSION['user']))
{
echo'
<li><a href="cart.php" class="btn btn-md"><span class="glyphicon glyphicon-
shopping-cart">Cart</span></a></li>
<li><a href="destroy.php" class="btn btn-md"> <span class="glyphicon
glyphicon-log-out">LogOut</span></a></li>
';
}
?>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>

<div id="top" >


<div id="searchbox" class="container-fluid" style="width:112%;margin-left:-
6%;margin-right:-6%;">
<div>
<form role="search" action="Result.php" method="post">
<input type="text" name="keyword" class="form-control" placeholder="Search
for a Book , Author Or Category" style="width:80%;margin:20px 10% 20px 10%;">
</form>
</div>
</div>

<?php
include "dbconnect.php";
if(isset($_GET['value']))
{
$_SESSION['category']=$_GET['value'];
}
$category=$_SESSION['category'];
if(isset($_POST['sort']))
{
if($_POST['sort']=="price")
{ $query = "SELECT * FROM products WHERE Category='$category' ORDER
BY Price";
$result = mysqli_query ($con,$query)or die(mysqli_error($con));
?>
<script type="text/javascript">
document.getElementById('select').Selected=$_POST['sort'];
</script>
<?php
}
else
if($_POST['sort']=="priceh")
{ $query = "SELECT * FROM products WHERE Category='$category' ORDER
BY Price DESC";
$result = mysqli_query ($con,$query)or die(mysqli_error($con));
}
else
if($_POST['sort']=="discount")
{ $query = "SELECT * FROM products WHERE Category='$category' ORDER
BY Discount DESC";
$result = mysqli_query ($con,$query)or die(mysqli_error($con));
}
else
if($_POST['sort']=="discountl")
{ $query = "SELECT * FROM products WHERE Category='$category' ORDER
BY Discount";
$result = mysqli_query ($con,$query)or die(mysqli_error($con));
}
}
else
{ $query = "SELECT * FROM products WHERE Category='$category'";
$result = mysqli_query ($con,$query)or die(mysqli_error($con));
}
$i=0;
echo '<div class="container-fluid" id="books">
<div class="row">
<div class="col-xs-12 text-center" id="heading">
<h2 style="color:rgb(228, 55, 25);text-transform:uppercase;margin-bottom:0px;">
'. $category .' STORE </h2>
</div>
</div>
<div class="container fluid">
<div class="row">
<div class="col-sm-5 col-sm-offset-6 col-md-5 col-md-offset-7 col-lg-4 col-lg-
offset-8">
<form action="';echo $_SERVER['PHP_SELF'];echo'" method="post"
class="pull-right">
<label for="sort">Sort by &nbsp: &nbsp</label>
<select name="sort" id="select" onchange="form.submit()">
<option value="default" name="default"
selected="selected">Select</option>
<option value="price" name="price">Low To High Price </option>
<option value="priceh" name="priceh">Highest To Lowest Price
</option>
<option value="discountl" name="discountl">Low To High Discount
</option>
<option value="discount" name="discount">Highest To Lowest
Discount</option>
</select>
</form>
</div>
</div>
</div>';

if(mysqli_num_rows($result) > 0)
{
while($row = mysqli_fetch_assoc($result))
{
$path="img/books/" .$row['PID'].".jpg";
$description="description.php?ID=".$row["PID"];
if($i%4==0)
echo '<div class="row">';
echo'
<a href="'.$description.'">
<div class="col-sm-6 col-md-3 col-lg-3 text-center">
<div class="book-block" style="border :3px solid #DEEAEE;">
<img class="book block-center img-responsive" src="'.$path.'">
<hr>
' . $row["Title"] . '<br>
' . $row["Price"] .' &nbsp
<span style="text-decoration:line-through;color:#828282;"> ' .
$row["MRP"] .' </span>
<span class="label label-warning">'. $row["Discount"] .'%</span>
</div>
</div>

</a> ';
$i++;
if($i%4==0)
echo '</div>';
}
}
echo '</div>';
?>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="js/bootstrap.min.js"></script>
</body>
</html>
<!--
<script>
$('#my_select').change(function() {
// assign the value to a variable, so you can test to see if it is working
var selectVal = $('#my_select :selected').val();
alert(selectVal);
});
</script>

-->
REGISTER.PHP

<?php

include "dbconnect.php";

if(isset($_POST['submit']))
{
if($_POST['submit']=="register")
{
$username=$_POST['register_username'];
$password=$_POST['register_password'];
$query="select * from users where UserName = '$username'";
$result=mysqli_query($con,$query) or die(mysql_error);
if(mysqli_num_rows($result)>0)
{
header("Location: index.php?register=" . "Username is already taken...Use different
username");
}
else
{
$query ="INSERT INTO users VALUES ('$username','$password')";
$result=mysqli_query($con,$query);
header("Location: index.php?register=" . "Successfully Registered!!");
}
}
}

?>
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";
?>
BOOK.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>
<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">
<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
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']);
$_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>
<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";

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>
<?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>
<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";
?>
EDIT.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);
}

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;
} else {
header("Location: admin_edit.php?bookisbn=$isbn");
}
?>

PURCHASE.PHP

<?php
session_start();
$_SESSION['err'] = 1;
foreach($_POST as $key => $value){
if(trim($value) == ''){
$_SESSION['err'] = 0;
}
break;
}

if($_SESSION['err'] == 0){
header("Location: checkout.php");
} else {
unset($_SESSION['err']);
}

$_SESSION['ship'] = array();
foreach($_POST as $key => $value){
if($key != "submit"){
$_SESSION['ship'][$key] = $value;
}
}
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']))){
?>
<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>
<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">
<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";
?>
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>
<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";
?>

You might also like