0% found this document useful (0 votes)
78 views75 pages

E Commerce Database Project Report

Uploaded by

parthsharma00004
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)
78 views75 pages

E Commerce Database Project Report

Uploaded by

parthsharma00004
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/ 75

lOMoARcPSD|51426956

E Commerce database project report

Computer Science and Engineering (Visvesvaraya Technological University)

Scan to open on Studocu

Studocu is not sponsored or endorsed by any college or university


Downloaded by Parth Sharma ([email protected])
lOMoARcPSD|51426956

E-COMMERCE DATABASE

INTRODUCTION

Computer plays an important role in our daily life.


Anything we want we can get only in one mouse click.
Speed, reliability and accuracy of the computer make
it a powerful tool for different purposes. A very
important and basic need of today’s modern business
world is the quick availability and processing of
information using computer. One can easily get the
type of required information within a fraction of a
second. The project that I have taken is also in this
category which is used in our daily life whenever we
want to purchase some items we can easily get them
at our home.
E-commerce (electronic commerce) is the buying and
selling of goods and services, or the transmitting of
funds or data, over an electronic network, primarily the
internet. These business transactions occur either as
business-to-business (0), business-to-consumer
(B2C), consumer- to-consumer or consumer-to-
business. The terms e-commerce and e-business are
often used interchangeably. The term e-tail is also
sometimes used in reference to the transactional
processes for online shopping.

Page 1

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE

OBJECTIVE

Developing a GUI based automated system, which


will cover all the information Related to the all
products which is used in our daily life. For
example – Mobiles Phones, Laptops, Clothes,
Books, Electronic Items and many more. So by this
GUI based automated system a user want to
purchase something then it only a mouse click
away to purchase these products.
The e-commerce is mainly useful for ho haven’t time
to go shopping or for comfortably to the customers.
Those are just entered into this website and bought
they want at any time they can visit the web-site.
Customer will choose different items like mobile,
laptops, etc. This website is based on this formal.
After chosen items they pay bill thorough pay pal
process. Customer will get their items just sitting at
home.

Page 2

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE

NEEDS OF ECOMMERCE

The “Ecommerce” is developed according the current need in


different Fields. This is Ecommerce Website which provides facility
for purchasing Mobiles, Laptops, tabs and many more items. So by
using this system users which want to purchase some products will
first Register an account on this portal then Login through their
Username and Password, and then Select items which they want to
purchase and add them to cart and finally checkout by giving
payment details. So by using this portal users can easily purchase
products from their home.

Methodology Development Model

Page 3

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE

The sequential phases in Waterfall model are −


 Requirement Gathering and analysis − All possible
requirements of the system to be developed are captured in this
phase and documented in a requirement specification
document.

 System Design − The requirement specifications from first phase


are studied in this phase and the system design is prepared. This
system design helps in specifying hardware and system
requirements and helps in defining the overall system
architecture.

 Implementation − With inputs from the system design, the


system is first developed in small programs called units, which are
integrated in the next phase. Each unit is developed and tested
for its functionality, which is referred to as Unit Testing.

 Integration and Testing − All the units developed in the


implementation phase are integrated into a system after testing of
each unit. Post integration the entire system is tested for any
faults and failures.

 Deployment of system − Once the functional and non-functional


testing is done; the product is deployed in the customer
environment or released into the market.

 Maintenance − There are some issues which come up in the client


environment. To fix those issues, patches are released. Also to
enhance the product some better versions are released.
Maintenance is done to deliver these changes in the customer
environment
Page 4

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE

TOOLS AND TECHNIQUE

Specification Requirement
External Interfaces
- This interface will be actual interface through which the
user will communication with the application and perform the
desired tasks.

Admin
login I.D:
Role: Admin wishes to login to the
system Precondition: Username and
Password
Success end Condition: Main option of screen display
Failed end Condition: User has entered
incorrect Username
and Password or both

Page 5

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE

Edit

ID:
Precondition: User has successfully navigated to search
result Success end Condition: User has successfully
made the changes.

1. To edit user records in the data base, first search the record you want
to edit then click on ‘edit’ button.
2. Edit the particulars user that you want to change and click on’ Save’
button.

Page 6

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE

DATABASE

Page 7

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE

Data Design
Data Model: A database model is a type of data
model that determines the logical structure of a
database and fundamentally determines in
which manner data can be stored, organized
and manipulated.

Level 0

Figure: Dataflow

Page 8

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE

Figure: ER diagram

Page 9

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE

Figure: Use case Diagram of


Ecommerce

1 Page 10

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

G-COMMERCE DATABASE

Figure: Schema Diagram

1 Page 11

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

I-COMMERCE DATABASE

Figure: Sequence Diagram

1 Page 12

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

K-COMMERCE DATABASE

Figure: Flowchart of Ecommerce

1 Page 13

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

M-COMMERCE DATABASE

Structure of the project


 Before Login
 Login
 Register
 Forget Password
 Administrator Login
 About Us
 Contact Us
 After Administrator Login
 Edit Website Details
 Add Brands
 Add Category
 Add Items
 Delete Brands
 Delete Category
 Delete Items
 Manage User
 See Users
 Users Shopping
 Add Users
 Delete Users
 Logout
 After User Login
 My Profile
 Edit Profile
 Change Password

1 Page 14

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

O-COMMERCE DATABASE

 Buy Products
 Categories (Controlled by Admin. Which can be
add it dynamically according to their needs)
 My Cart
 My Shopping’s
 Checkout
 Logout

1 Page 15

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

Q-COMMERCE DATABASE

SYSTEM ANALYSIS

The objective of the system analysis activity is to develop


structured system specification for the proposed system. The
structured system specification should describe what the
proposed system would do; independent of the technology,
which will be used to implement these requirements. The
structured system specification will be used to implement
these requirements. The structured system specification will
be called the essential model (also know as logical model).

The essential model may itself consist of multiple


models, modeling different aspect of the system. The data
flow diagrams may model the data and there relationships
and the state transition diagram may model time dependent
behavior of the system. The essential model thus consists
of the following.

 Context diagram
 Leveled data flow diagrams
 Process specification for elementary bubbles
 Data dictionary for the flow and stores on the DFDs.

1 Page 16

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

S-COMMERCE DATABASE

System Design

System design involves transformation of the user


implementation model into software design. The design
specification of the proposed system consists of the following:
 Database scheme
 Structure charts
 Pseudo codes for the modules in structure charts

Implementation

This activity includes programming, testing and integration of


modules into a progressively more complete system.
Implementation is the process of collect all the required
parts and assembles them into a major product.

1 Page 17

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

U-COMMERCE DATABASE

Test Generation
This activity generates a set of test data, which can be used to test
the new system before accepting it. In the test generation phase all
the parts are come which are to be tested to ensure that system
does not produce any error. If there are some errors then we remove
them and further it goes for accepting.

Problem Analysis

Ecommerce system is a computerized, online solution to the


various problems faced by the Product buyer and seller wishing to
outsource their software development work to a Provider at an
economical cost, thus achieving high performance, accuracy,
reliability and high speed of data retrieval.
In this system, there is a registration process each for the
Product buyer and seller. The Administrator of the site verifies the
Provider after his registration and if satisfied, assigns him a user
name and password.
Our site can be used by anyone who is searching for Products
whether he/she is first time visiting our site. Our site also provides
some discounted Products as same u get on any shop.
The software covers the following point while keeping in mind
user’s
requirement-:

 Fast online access of information about various Products.


 Search Products by keywords like functional area, experience and
also by initials of the Product’s name.
 Administrator will maintain the database and perform all
process. There are 2 categories of users-

1. General User

2. Registered Users

1 Page 18

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE

SOURCE
CODE
LOGIN PAGE

<?php include 'includes/session.php'; ?>


<?php
if(isset($_SESSION['user'])){
header('location: cart_view.php');
}
?>
<?php include 'includes/header.php'; ?>
<body class="hold-transition login-page">
<div class="login-box">
<?php
if(isset($_SESSION['error']))
{ echo "
<div class='callout callout-danger text-center'>
<p>".$_SESSION['error']."</p>
</div>
";
unset($_SESSION['error']);
}
if(isset($_SESSION['success']
)){ echo "
<div class='callout callout-success text-center'>
<p>".$_SESSION['success']."</p>
</div>
";
unset($_SESSION['success']);
}
?>
<div class="login-box-body">
<p class="login-box-msg">Sign in to start your session</p>

<form action="verify.php" method="POST">


<div class="form-group has-feedback">
<input type="email" class="form-control" name="email" placeholder="Email"
required>
<span class="glyphicon glyphicon-envelope form-control-feedback"></span>
</div>
<div class="form-group has-feedback">
<input type="password" class="form-control" name="password" placeholder="Password"
required>
<span class="glyphicon glyphicon-lock form-control-feedback"></span>
</div>
<div class="row">
<div class="col-xs-4">
<button type="submit" class="btn btn-primary btn-block btn-flat"
name="login"><i class="fa fa-sign-in"></i> Sign In</button>
</div>

1 Page 19

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE

</div>
</form>
<br>
<a href="password_forgot.php">I forgot my password</a><br>
<a href="signup.php" class="text-center">Register a new membership</a><br>
<a href="index.php"><i class="fa fa-home"></i> Home</a>
</div>
</div>
<?php include 'includes/scripts.php' ?>
</body>
</html>

Logout Page
<?
php session_start();
session_destroy(
);

header('location: index.php');
?>

Password Forgot
<?php include 'includes/session.php'; ?>
<?php include 'includes/header.php'; ?>
<body class="hold-transition login-page">
<div class="login-box">
<?php
if(isset($_SESSION['error']))
{ echo "
<div class='callout callout-danger text-center'>
<p>".$_SESSION['error']."</p>
</div>
";
unset($_SESSION['error']);
}
if(isset($_SESSION['success']
)){ echo "
<div class='callout callout-success text-center'>

2 Page 20

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE

<p>".$_SESSION['success']."</p>
</div>
";
unset($_SESSION['success']);
}
?>
<div class="login-box-body">
<p class="login-box-msg">Enter email associated with account</p>

<form action="reset.php" method="POST">


<div class="form-group has-feedback">
<input type="email" class="form-control" name="email" placeholder="Email"
required>
<span class="glyphicon glyphicon-envelope form-control-feedback"></span>
</div>
<div class="row">
<div class="col-xs-4">
<button type="submit" class="btn btn-primary btn-block btn-flat"
name="reset"><i class="fa fa-mail-forward"></i> Send</button>
</div>
</div>
</form>
<br>
<a href="login.php">I rememberd my password</a><br>
<a href="index.php"><i class="fa fa-home"></i> Home</a>
</div>
</div>

<?php include 'includes/scripts.php' ?>


</body>
</html>

Password reset
<?php include 'includes/session.php'; ?>
<?php
if(!isset($_GET['code']) OR !
isset($_GET['user'])){ header('location:
index.php');
exit();
}
?>
<?php include 'includes/header.php'; ?>
<body class="hold-transition login-page">
<div class="login-box">
<?php
if(isset($_SESSION['error']))
{ echo "
<div class='callout callout-danger text-center'>
<p>".$_SESSION['error']."</p>

2 Page 21

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE

</div>
";
unset($_SESSION['error']);
}
?>
<div class="login-box-body">
<p class="login-box-msg">Enter new password</p>

<form action="password_new.php?code=<?php echo $_GET['code']; ?>&user=<?php


echo
$_GET['user']; ?>" method="POST">
<div class="form-group has-feedback">
<input type="password" class="form-control" name="password" placeholder="New
password" required>
<span class="glyphicon glyphicon-lock form-control-feedback"></span>
</div>
<div class="form-group has-feedback">
<input type="password" class="form-control" name="repassword" placeholder="Re-
type password" required>
<span class="glyphicon glyphicon-log-in form-control-feedback"></span>
</div>
<div class="row">
<div class="col-xs-4">
<button type="submit" class="btn btn-primary btn-block btn-flat"
name="reset"><i class="fa fa-check-square-o"></i> Reset</button>
</div>
</div>
</form>
</div>
</div>
<?php include 'includes/scripts.php' ?>
</body>
</html>

RESET

<?
php use PHPMailer\PHPMailer\
PHPMailer; use PHPMailer\
PHPMailer\Exception;

include

'includes/session.php';

2 Page 22

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE
ail = $_POST['email'];
i

'

'

{
$
e
m

2 Page 23

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE

$conn = $pdo->open();

$stmt = $conn->prepare("SELECT *, COUNT(*) AS numrows FROM users


WHERE email=:email");
$stmt->execute(['email'=>$email]);
$row = $stmt->fetch();

if($row['numrows'] > 0){


//generate code

$set='123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$code=substr(str_shuffle($set), 0,
15); try{
$stmt = $conn->prepare("UPDATE users SET reset_code=:code
id=:id"); WHERE

$stmt->execute(['code'=>$code, 'id'=>$row['id']]);

$message = "
<h2>Password Reset</h2>
<p>Your Account:</p>
<p>Email: ".$email."</p>
<p>Please click the link below to reset your password.</p>
<a
href='http://localhost/ecommerce/password_reset.php?code=".$code."&user=".$row['id']."'>Reset
Password</a>
";

//Load phpmailer
require 'vendor/autoload.php';

$mail = new
PHPMailer(true); try {
//Server settings
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = '[email protected]';
$mail->Password = 'mysourcepass';
$mail->SMTPOptions =
array( 'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
$mail->SMTPSecure = 'ssl';
$mail->Port = 465;

$mail->setFrom('[email protected]');

//Recipients
$mail->addAddress($email);
$mail->addReplyTo('[email protected]');

2 Page 24

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE

//Content
$mail->isHTML(true);
$mail->Subject = 'ECommerce Site Password Reset';
$mail->Body = $message;

$mail->send();

$_SESSION['success'] = 'Password reset link sent';

}
catch (Exception $e) {
$_SESSION['error'] = 'Message could not be sent. Mailer Error: '.
>ErrorInfo; $mail-
}
}
catch(PDOException $e){
$_SESSION['error'] = $e->getMessage();
}
}
else
{ $_SESSION['error'] = 'Email not found';

$pdo->close();

}
else
{ $_SESSION['error'] = 'Input email associated with account';

header('location: password_forgot.php');

?>

SIGNUP PAGE
<?php include 'includes/session.php'; ?>
<?php
if(isset($_SESSION['user'])){
header('location: cart_view.php');
}

2 Page 25

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE
if(isset($_SESSION['captcha'])){

2 Page 26

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE

$now = time();
if($now >=
$_SESSION['captcha']){
unset($_SESSION['captcha']);
}
}

?>
<?php include 'includes/header.php'; ?>
<body class="hold-transition register-page">
<div class="register-box">
<?php
if(isset($_SESSION['error']))
{ echo "
<div class='callout callout-danger text-center'>
<p>".$_SESSION['error']."</p>
</div>
";
unset($_SESSION['error']);
}

if(isset($_SESSION['success']
)){ echo "
<div class='callout callout-success text-center'>
<p>".$_SESSION['success']."</p>
</div>
";
unset($_SESSION['success']);
}
?>
<div class="register-box-body">
<p class="login-box-msg">Register a new membership</p>

<form action="register.php" method="POST">


<div class="form-group has-feedback">
<input type="text" class="form-control" name="firstname" placeholder="Firstname"
value="<?php echo (isset($_SESSION['firstname'])) ? $_SESSION['firstname'] : '' ?>" required>
<span class="glyphicon glyphicon-user form-control-feedback"></span>
</div>
<div class="form-group has-feedback">
<input type="text" class="form-control" name="lastname"
placeholder="Lastname" value="<?php echo (isset($_SESSION['lastname'])) ?
$_SESSION['lastname'] : '' ?>" required>
<span class="glyphicon glyphicon-user form-control-feedback"></span>
</div>
<div class="form-group has-feedback">
<input type="email" class="form-control" name="email"
placeholder="Email" value="<?php echo (isset($_SESSION['email'])) ?
$_SESSION['email'] : '' ?>" required>
<span class="glyphicon glyphicon-envelope form-control-feedback"></span>
</div>
<div class="form-group has-feedback">
<input type="password" class="form-control" name="password" placeholder="Password"
required>
<span class="glyphicon glyphicon-lock form-control-feedback"></span>

2 Page 27

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE
</div>
<div class="form-group has-feedback">

2 Page 28

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE

<input type="password" class="form-control" name="repassword"


placeholder="Retype password" required>
<span class="glyphicon glyphicon-log-in form-control-feedback"></span>
</div>
<?php
if(!
isset($_SESSION['captcha'])){
echo '
<di class="form-group" style="width:100%;">
<div class="g-recaptcha" data-
sitekey="6LevO1IUAAAAAFX5PpmtEoCxwae- I8cCQrbhTfM6"></div>
</di>
';
}
?>
<hr>
<div class="row">
<div class="col-xs-4">
<button type="submit" class="btn btn-primary btn-block btn-flat"
name="signup"><i class="fa fa-pencil"></i> Sign Up</button>
</div>
</div>
</form>
<br>
<a href="login.php">I already have a membership</a><br>
<a href="index.php"><i class="fa fa-home"></i> Home</a>
</div>
</div>

<?php include 'includes/scripts.php' ?>


</body>
</html>

VERIFY
<?
php include 'includes/session.php';
$conn = $pdo->open();

if(isset($_POST['login'])){

$email =
$_POST['email'];
$password =

$_POST['password']; try{

$stmt = $conn->prepare("SELECT *, COUNT(*) AS numrows FROM users


WHERE email = :email");
$stmt->execute(['email'=>$email]);
2 Page 29

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE
$row = $stmt->fetch();

2 Page 30

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE

if($row['numrows'] > 0){


if($row['status']){
if(password_verify($password, $row['password'])){
if($row['type']){
$_SESSION['admin'] = $row['id'];
}
else
{ $_SESSION['user'] = $row['id'];

} }
else
{
$_SESSION['error'] = 'Incorrect Password';
}
}
else
{ $_SESSION['error'] = 'Account not activated.';

} }
else
{
$_SESSION['error'] = 'Email not found';
}
}
catch(PDOException $e){
echo "There is some problem in connection: " . $e->getMessage();
}

}
else
{ $_SESSION['error'] = 'Input login credentails first';

$pdo->close();

header('location:

login.php');

?
CATEGORY

<?php include 'includes/session.php'; ?>


<?php
$slug = $_GET['category'];

$conn = $pdo-

>open(); try{
$stmt = $conn->prepare("SELECT * FROM category WHERE cat_slug = :slug");
$stmt->execute(['slug' => $slug]);
$cat = $stmt->fetch();
$catid = $cat['id'];
}

2 Page 31

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE
catch(PDOException $e){
echo "There is some problem in connection: " . $e->getMessage();
}

2 Page 32

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE

$pdo->close();

?>
<?php include 'includes/header.php'; ?>
<body class="hold-transition skin-blue layout-top-nav">
<div class="wrapper">

<?php include 'includes/navbar.php'; ?>

<div class="content-wrapper">
<div class="container">
<!-- Main content -->
<section class="content">
<div class="row">
<div class="col-sm-9">
<h1 class="page-header"><?php echo $cat['name']; ?></h1>
<?php

$conn = $pdo->open();

try{
$inc = 3;
$stmt = $conn->prepare("SELECT * FROM
WHERE category_id = products
:catid");
$stmt->execute(['catid' =>
$catid]); foreach ($stmt as $row) {
$image = (!empty($row['photo'])) ?
'images/'.$row['photo'] : 'images/noimage.jpg';
$inc = ($inc == 3) ? 1 : $inc + 1;
if($inc == 1) echo "<div
class='row'>"; echo "
<div class='col-sm-4'>
<div class='box box-solid'>
<div class='box-body
prod-body'>
<img
src='".$image."' width='100%' height='230px' class='thumbnail'>
<h5><a
href='product.php?product=".$row['slug']."'>".$row['name']."</a></h5>
</div>
<div class='box-footer'>
<b>&#36;
".number_format($row['price'], 2)."</b>
</div>
</div>
</div>
";
if($inc == 3) echo "</div>";
}
if($inc == 1) echo "<div
class='col-sm-4'></div></div>";
class='col-sm-4'></div><div if($inc == 2)
4'></div></div>";
echo"<div class='col-sm-

2 Page 33

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE
}

2 Page 34

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE

catch(PDOException $e){
echo "There is some problem in connection: "
$e- .
>getMessage();
}

$pdo->close();

?
>
</div>
<div class="col-sm-3">
<?php include 'includes/sidebar.php'; ?>
</div>
</div>
</section>

</div>
</div>

<?php include 'includes/footer.php'; ?>


</div>

<?php include 'includes/scripts.php'; ?>


</body>
</html>

CART ADD
<?
php include 'includes/session.php';

$conn = $pdo->open();

$output = array('error'=>false);

$id = $_POST['id'];
$quantity =
$_POST['quantity'];

if(isset($_SESSION['user'])){
$stmt = $conn->prepare("SELECT *, COUNT(*) AS numrows FROM cart WHERE
user_id=:user_id AND product_id=:product_id");
$stmt->execute(['user_id'=>$user['id'], 'product_id'=>$id]);
$row = $stmt->fetch();

2 Page 35

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE
if($row['numrows'] < 1){
try{

2 Page 36

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE

$stmt = $conn->prepare("INSERT INTO cart (user_id, product_id,


quantity) VALUES (:user_id, :product_id, :quantity)");
$stmt->execute(['user_id'=>$user['id'], 'product_id'=>$id,
'quantity'=>$quantity]);
$output['message'] = 'Item added to cart';

}
catch(PDOException $e){
$output['error'] = true;
$output['message'] = $e->getMessage();
}
}
else
{ $output['error'] = true;
$output['message'] = 'Product already in cart';

} }
else
{
if(!isset($_SESSION['cart'])){
$_SESSION['cart'] = array();
}

$exist = array();

foreach($_SESSION['cart'] as $row){
array_push($exist, $row['productid']);
}
if(in_array($id, $exist)){
$output['error'] = true;
$output['message'] = 'Product already in cart';
}
else
{ $data['productid'] = $id;
$data['quantity'] = $quantity;

if(array_push($_SESSION['cart'], $data)){
$output['message'] = 'Item added to cart';
}
else
{ $output['error'] = true;
$output['message'] = 'Cannot add item to cart';

}
}

$pdo->close();
echo json_encode($output);

?>

3 Page 37

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE

CART
<?
php DELETE
include 'includes/session.php';

$conn = $pdo->open();

$output = array('error'=>false);
$id = $_POST['id'];

if(isset($_SESSION['user'])){
try{
$stmt = $conn->prepare("DELETE FROM cart WHERE id=:id");
$stmt->execute(['id'=>$id]);
$output['message'] = 'Deleted';

}
catch(PDOException $e){
$output['message'] = $e->getMessage();
}
}
else
{ foreach($_SESSION['cart'] as $key =>
$row){ if($row['productid'] == $id){
unset($_SESSION['cart'][$key]);
$output['message'] = 'Deleted';
}
}
}

$pdo->close();
echo json_encode($output);

?>

CART UPDATE
<?
php include 'includes/session.php';

$conn = $pdo->open();

$output = array('error'=>false);

$id = $_POST['id'];
$qty = $_POST['qty'];

if(isset($_SESSION['user'])){
try{
3 Page 38

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE

$stmt = $conn->prepare("UPDATE cart SET quantity=:quantity


id=:id"); WHERE

$stmt->execute(['quantity'=>$qty, 'id'=>$id]);
$output['message'] = 'Updated';
}
catch(PDOException $e){
$output['message'] = $e->getMessage();
}
}
else
{ foreach($_SESSION['cart'] as $key =>
$row){ if($row['productid'] == $id){
$_SESSION['cart'][$key]['quantity'] = $qty;
$output['message'] = 'Updated';
}
}
}

$pdo->close();
echo json_encode($output);

?>

CART TOTAL
<?
php include

'includes/session.php';

if(isset($_SESSION['user'])){
$conn = $pdo->open();

$stmt = $conn->prepare("SELECT * FROM cart LEFT JOIN products on


products.id=cart.product_id WHERE
user_id=:user_id");
$stmt->execute(['user_id'=>$user['id']]);

$total = 0;
foreach($stmt as $row)
{
$subtotal = $row['price'] * $row['quantity'];
$total += $subtotal;
}

$pdo->close();

echo json_encode($total);
}
3 Page 39

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE
?>

3 Page 40

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE

SEARCH
<?php include 'includes/session.php'; ?>
<?php include 'includes/header.php'; ?>
<body class="hold-transition skin-blue layout-top-nav">
<div class="wrapper">

<?php include 'includes/navbar.php'; ?>

<div class="content-wrapper">
<div class="container">

<!-- Main content -->


<section class="content">
<div class="row">
<div class="col-sm-9">
<?php

$conn = $pdo->open();

$stmt = $conn->prepare("SELECT COUNT(*) AS numrows FROM


products WHERE name LIKE :keyword");
$stmt->execute(['keyword' => '%'.$_POST['keyword'].'%']);
$row = $stmt->fetch();
if($row['numrows'] < 1){
echo '<h1 class="page-header">No results found for
<i>'.$_POST['keyword'].'</i></h1>';
}
else{
echo '<h1 class="page-header">Search results for
<i>'.$_POST['keyword'].'</i></h1>';
try{
$inc = 3;
$stmt = $conn->prepare("SELECT * FROM
WHERE name products

LIKE :keyword"); '%'. $stmt->execute(['keyword' =>

$_POST['keyword'].'%']);
foreach ($stmt as $row) {
$highlighted = preg_filter('/' .
preg_quote($_POST['keyword'], '/') . '/i', '<b>$0</b>', $row['name']);
$image = (!empty($row['photo'])) ?
'images/'.$row['photo'] : 'images/noimage.jpg';
$inc = ($inc == 3) ? 1 : $inc + 1;
if($inc == 1) echo "<div
class='row'>"; echo "
<div class='col-sm-4'>
<div class='box box-solid'>
<div class='box-body
prod-body'>
<img
src='".$image."' width='100%' height='230px' class='thumbnail'>
<h5><a

3 Page 41

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE

href='product.php?product=".$row['slug']."'>".$highlighted."</a></h5>
</div>
<div class='box-footer'>
<b>&#36;
".number_format($row['price'], 2)."</b>
</div>
</div>
</div>
";
if($inc == 3) echo "</div>";
}
if($inc == 1) echo "<div
class='col-sm-4'></div></div>";
class='col-sm-4'></div><div if($inc == 2)
4'></div></div>";
echo"<div class='col-sm-

}
catch(PDOException $e){
echo "There is some problem in connection: "
$e- .
>getMessage();
}
}

$pdo->close();

?>
</div>
<div class="col-sm-3">
<?php include 'includes/sidebar.php'; ?>
</div>
</div>
</section>

</div>
</div>

<?php include 'includes/footer.php'; ?>


</div>

<?php include 'includes/scripts.php'; ?>


</body>
</html>

REGISTER
<?
php use PHPMailer\PHPMailer\
PHPMailer; use PHPMailer\
PHPMailer\Exception;

include

3 Page 42

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE
' sset($_POST['signup'])){
$firstname = $_POST['firstname'];
i

'

3 Page 43

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE

$lastname = $_POST['lastname'];
$email = $_POST['email'];
$password = $_POST['password'];
$repassword = $_POST['repassword'];

$_SESSION['firstname'] = $firstname;
$_SESSION['lastname'] = $lastname;
$_SESSION['email'] = $email;

if(!isset($_SESSION['captcha'])){
require('recaptcha/src/autoload.php');
$recaptcha = new
\ReCaptcha\ReCaptcha('6LevO1IUAAAAAFCCiOHERRXjh3VrHa5oywciMKcw', new
\ReCaptcha\RequestMethod\SocketPost());
$resp = $recaptcha->verify($_POST['g-recaptcha-
response'],
$_SERVER['REMOTE_ADDR']);

if (!$resp->isSuccess()){
$_SESSION['error'] = 'Please answer recaptcha
correctly'; header('location: signup.php');
exit();
}
else
{ $_SESSION['captcha'] = time() + (10*60);

if($password != $repassword){
$_SESSION['error'] = 'Passwords did not
match'; header('location: signup.php');
}
else{
$conn = $pdo->open();

$stmt = $conn->prepare("SELECT COUNT(*) AS numrows FROM users


email=:email"); WHERE

$stmt->execute(['email'=>$email]);
$row = $stmt->fetch();
if($row['numrows'] > 0){
$_SESSION['error'] = 'Email already
} taken'; header('location: signup.php');
else{
$now = date('Y-m-d');
$password = password_hash($password, PASSWORD_DEFAULT);

//generate code

$set='123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$code=substr(str_shuffle($set), 0, 12);

try{
$stmt = $conn->prepare("INSERT INTO users (email,
3 Page 44

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE
password,

3 Page 45

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE

firstname, lastname, activate_code, created_on) VALUES (:email, :password, :firstname,


:lastname,
:code, :now)");

$stmt->execute(['email'=>$email,
'password'=>$password
, 'firstname'=>$firstname, 'lastname'=>$lastname, 'code'=>$code, 'now'=>$now]);
$userid = $conn->lastInsertId();

$message = "
<h2>Thank you for Registering.</h2>
<p>Your Account:</p>
<p>Email: ".$email."</p>
<p>Password: ".$_POST['password']."</p>
<p>Please click the link below to activate
your
account.</p>
<a
href='http://localhost/ecommerce/activate.php?code=".$code."&user=".$userid."'>Activate
Account</a>"; //Load phpmailer
require 'vendor/autoload.php';

$mail = new
PHPMailer(true); try {
//Server settings
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = '[email protected]';
$mail->Password = 'mysourcepass';
$mail->SMTPOptions =
array( 'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,

'allow_self_signed' => true


)
);
$mail->SMTPSecure = 'ssl';
$mail->Port = 465;

$mail->setFrom('[email protected]');

//Recipients
$mail->addAddress($email);
$mail->addReplyTo('[email protected]');

//Content
$mail->isHTML(true);
$mail->Subject = 'ECommerce Site Sign Up';
$mail->Body = $message;

$mail->send();

3 Page 46

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE
unset($_SESSION['firstname'
]);
unset($_SESSION['lastname']
);

3 Page 47

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE

unset($_SESSION['email']);

$_SESSION['success'] = 'Account created. Check your email to


activate.';
header('location: signup.php');

}
catch (Exception $e) {
$_SESSION['error'] = 'Message could not be sent. Mailer
'.$mail->ErrorInfo; Error:

header('location: signup.php');
}

}
catch(PDOException $e){
$_SESSION['error'] = $e-
>getMessage(); header('location:
register.php');
}

$pdo->close();

}
else{
$_SESSION['error'] = 'Fill up signup form
first'; header('location: signup.php');
}

?>

RECAPTCHA
<?php

namespace

ReCaptcha; class

ReCaptcha
{
3 Page 48

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE
const VERSION =
'php_1.1.2'; private $secret;

3 Page 49

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE

private $requestMethod;
public function construct($secret, RequestMethod $requestMethod = null)
{
if (empty($secret)) {
throw new \RuntimeException('No secret provided');
}

if (!is_string($secret)) {
throw new \RuntimeException('The provided secret must be a string');
}

$this->secret = $secret;

if (!is_null($requestMethod)) {
$this->requestMethod = $requestMethod;
} else {
$this->requestMethod = new RequestMethod\Post();
}
}
public function verify($response, $remoteIp = null)
{
// Discard empty solution
submissions if (empty($response)) {
$recaptchaResponse = new Response(false, array('missing-input-
response')); return $recaptchaResponse;
}

$params = new RequestParameters($this->secret, $response, $remoteIp, self::VERSION);


$rawResponse = $this->requestMethod-
>submit($params); return
Response::fromJson($rawResponse);
}
}

REQUEST METHOD
<?php

namespace ReCaptcha;
public function submit(RequestParameters $params);
}

3 Page 50

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE

RESPONSE
<?php

namespace ReCaptcha;

interface

RequestMethod
{
public function submit(RequestParameters $params);
}

REQUEST PARAMETER
<?php
namespace
ReCaptcha; class
RequestParameters
{
private $secret;
private
$response;
private $remoteIp;
private $version;
public function construct($secret, $response, $remoteIp = null, $version = null)
{
$this->secret = $secret;
$this->response = $response;
$this->remoteIp = $remoteIp;
$this->version = $version;
}
public function toArray()
{
$params = array('secret' => $this->secret, 'response' => $this->response);

if (!is_null($this->remoteIp)) {
$params['remoteip'] = $this->remoteIp;
}

if (!is_null($this->version)) {
$params['version'] = $this->version;
}

3 Page 51

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE
return $params;
}

3 Page 52

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE

public function toQueryString()


{
return http_build_query($this->toArray(), '', '&');
}
}

ECOMMERCE
-- phpMyAdmin SQL Dump
-- version 5.0.2
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Dec 31, 2020 at 11:46 AM
-- Server version: 10.4.14-MariaDB
-- PHP Version: 7.4.10

SET SQL_MODE =
"NO_AUTO_VALUE_ON_ZERO"; START
TRANSACTION;
SET time_zone = "+00:00";
--
-- Database: `ecomm`
--

-- --------------------------------------------------------

--
-- Table structure for table `cart`
--

CREATE TABLE `cart` (


`id` int(11) NOT NULL,
`user_id` int(11) NOT NULL,
`product_id` int(11) NOT NULL,
`quantity` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--

4 Page 53

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE

-- Table structure for table `category`


--

CREATE TABLE `category` (


`id` int(11) NOT NULL,
`name` varchar(100) NOT NULL,
`cat_slug` varchar(150) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `category`
--

INSERT INTO `category` (`id`, `name`, `cat_slug`)


VALUES (1, 'Laptops', 'laptops'),
(2, 'Desktop PC', 'desktop-pc'),
(3, 'Tablets', 'tablets'),
(4, 'Smart Phones', '');

-- --------------------------------------------------------

--
-- Table structure for table `details`
--

CREATE TABLE `details` (


`id` int(11) NOT NULL,
`sales_id` int(11) NOT NULL,
`product_id` int(11) NOT NULL,
`quantity` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `details`
--

INSERT INTO `details` (`id`, `sales_id`, `product_id`, `quantity`)


VALUES (14, 9, 11, 2),
(15, 9, 13, 5),
(16, 9, 3, 2),
(17, 9, 1, 3),
(18, 10, 13, 3),
(19, 10, 2, 4),
(20, 10, 19, 5);

-- --------------------------------------------------------
--
-- Table structure for table `products`
--

CREATE TABLE `products` (


`id` int(11) NOT NULL,
`category_id` int(11) NOT NULL,
`name` text NOT NULL,

4 Page 54

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE

`description` text NOT NULL,


`slug` varchar(200) NOT NULL,
`price` double NOT NULL,
`photo` varchar(200) NOT NULL,
`date_view` date NOT NULL,
`counter` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `products`
--

INSERT INTO `products` (`id`, `category_id`, `name`, `description`, `slug`, `price`, `photo`,
`date_view`,
`counter`) VALUES
-- Table structure for table `sales`
--

CREATE TABLE `sales` (


`id` int(11) NOT NULL,
`user_id` int(11) NOT NULL,
`pay_id` varchar(50) NOT NULL,
`sales_date` date NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `sales`
--

INSERT INTO `sales` (`id`, `user_id`, `pay_id`, `sales_date`)


VALUES (9, 9, 'PAY-1RT494832H294925RLLZ7TZA', '2018-
05-10'),
(10, 9, 'PAY-21700797GV667562HLLZ7ZVY', '2018-05-10');

-- --------------------------------------------------------

--
-- Table structure for table `users`
--

CREATE TABLE `users` (


`id` int(11) NOT NULL,
`email` varchar(200) NOT NULL,
`password` varchar(60) NOT NULL,
`type` int(1) NOT NULL,
`firstname` varchar(50) NOT NULL,
`lastname` varchar(50) NOT NULL,
`address` text NOT NULL,
`contact_info` varchar(100) NOT NULL,
`photo` varchar(200) NOT NULL,
`status` int(1) NOT NULL,
`activate_code` varchar(15) NOT NULL,
`reset_code` varchar(15) NOT NULL,
`created_on` date NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

4 Page 55

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE

--
-- Dumping data for table `users`
--

INSERT INTO `users` (`id`, `email`, `password`, `type`, `firstname`, `lastname`, `address`,
`contact_info`,
`photo`, `status`, `activate_code`, `reset_code`, `created_on`) VALUES
(1, '[email protected]',
'$2y$10$0SHFfoWzz8WZpdu9Qw//E.tWamILbiNCX7bqhy3od0gvK5.kSJ8N2', 1, 'IT',
'SOURCECODE', '', '', 'logo.png', 1, '', '', '2020-12-30'),
(13, '[email protected]',
'$2y$10$THCiaipRqs51LgZNNSp7henK8SJ17r7abaH44slwjXavv/nVEw29e', 0, 'angel jude',
'suarez', 'Himamaylan City', '09458423256',

'cover.jpg', 1, '', '', '2020-12-30');

--
-- Indexes for dumped tables
--

--
-- Indexes for table `cart`
--
ALTER TABLE `cart`
ADD PRIMARY KEY (`id`);

--
-- Indexes for table `category`
--
ALTER TABLE
`category` ADD
PRIMARY KEY (`id`);

--
-- Indexes for table `details`
--
ALTER TABLE `details`
ADD PRIMARY KEY
(`id`);
--
-- Indexes for table `products`
--
ALTER TABLE
`products` ADD
PRIMARY KEY (`id`);

--
-- Indexes for table `sales`
--
ALTER TABLE `sales`
ADD PRIMARY KEY (`id`);

--
-- Indexes for table `users`

4 Page 56

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE
--
ALTER TABLE `users`
ADD PRIMARY KEY (`id`);

4 Page 57

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `cart`
--
ALTER TABLE `cart`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10;

--
-- AUTO_INCREMENT for table `category`
--
ALTER TABLE `category`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;

--
-- AUTO_INCREMENT for table `details`
--
ALTER TABLE `details`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=21;

--
-- AUTO_INCREMENT for table `products`
--
ALTER TABLE `products`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=30;

--
-- AUTO_INCREMENT for table `sales`
--
ALTER TABLE `sales`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11;

--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,
AUTO_INCREMENT=14; COMMIT;

4 Page 58

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE

USERS
<?php include 'includes/session.php'; ?
>
<?php include 'includes/header.php'; ?>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">

<?php include 'includes/navbar.php'; ?>


<?php include 'includes/menubar.php'; ?>

<!-- Content Wrapper. Contains page content -->


<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
Users
</h1>
<ol class="breadcrumb">
<li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
<li class="active">Users</li>
</ol>
</section>

<!-- Main content -->


<section class="content">
<?php
if(isset($_SESSION['error'])){
echo "
<div class='alert alert-danger alert-dismissible'>
<button type='button' class='close' data-dismiss='alert' aria-
hidden='true'>&times;</button>
<h4><i class='icon fa fa-warning'></i> Error!</h4>
".$_SESSION['error']."
</div>
";
unset($_SESSION['error']);
}
if(isset($_SESSION['success'])){
echo "
<div class='alert alert-success alert-dismissible'>
<button type='button' class='close' data-dismiss='alert' aria-
hidden='true'>&times;</button>
<h4><i class='icon fa fa-check'></i>
Success!</h4> ".$_SESSION['success']."
</div>
";
unset($_SESSION['success']);
}
?>
<div class="row">
<div class="col-xs-12">
<div class="box">
<div class="box-header with-border">

4 Page 59

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE

<a href="#addnew" data-toggle="modal" class="btn btn-primary btn-


sm btn-flat"><i class="fa fa-plus"></i> New</a>
</div>
<div class="box-body">
<table id="example1" class="table table-bordered">
<thead>
<th>Photo</th>
<th>Email</th>
<th>Name</th>
<th>Status</th>
<th>Date Added</th>
<th>Tools</th>
</thead>
<tbody>
<?php
$conn = $pdo->open();

try{
$stmt = $conn->prepare("SELECT * FROM
WHERE users
type=:type");
$stmt->execute(['type'=>0]);
foreach($stmt as $row){
$image = (!empty($row['photo'])) ?
'../images/'.$row['photo'] : '../images/profile.jpg';
$status = ($row['status']) ? '<span class="label
label-success">active</span>' : '<span class="label label-danger">not verified</span>';
$active = (!$row['status']) ? '<span class="pull-
right"><a href="#activate" class="status" data-toggle="modal" data-id="'.$row['id'].'"><i class="fa
fa- check-square-o"></i></a></span>' : '';
echo
"
<tr> <td>
<img src='".$image."' height='30px'
width='30px'>
<span class='pull-right'><a
href='#edit_photo' class='photo' data-toggle='modal' data-id='".$row['id']."'><i class='fa
fa- edit'></i></a></span>
</td>
<td>".$row['email']."</td>
<td>".$row['firstname'].'
'.$row['lastname']."</td>
<td> ".
$status."
".$active."
</td>
<td>".date('M d, Y',
strtotime($row['created_on']))."</td>
<td>
<a href='cart.php?user=".$row['id']."'
class='btn btn-info btn-sm btn-flat'><i class='fa fa-search'></i> Cart</a>
<button class='btn btn-success btn-sm
edit btn-flat' data-id='".$row['id']."'><i class='fa fa-edit'></i> Edit</button>
<button class='btn btn-danger btn-sm
delete btn-flat' data-id='".$row['id']."'><i class='fa fa-trash'></i> Delete</button>

4 Page 60

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE

</td>
</tr>
";
}
}
catch(PDOException
$e){ echo $e-
>getMessage();
}

$pdo->close();
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</section>

</div>
<?php include 'includes/footer.php'; ?>
<?php include 'includes/users_modal.php'; ?>

</div>
<!-- ./wrapper -->

<?php include 'includes/scripts.php'; ?>


<script>
$(function(){

$(document).on('click', '.edit', function(e){


e.preventDefault();
$('#edit').modal('show');
var id = $(this).data('id');
getRow(id);
});

$(document).on('click', '.delete', function(e)


{ e.preventDefault();
$('#delete').modal('show');
var id = $(this).data('id');
getRow(id);
});

$(document).on('click', '.photo', function(e)


{ e.preventDefault();
var id = $(this).data('id');
getRow(id);
});

$(document).on('click', '.status', function(e)


{ e.preventDefault();
var id = $(this).data('id');
getRow(id);

4 Page 61

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE

});

});

function getRow(id){
$.ajax({
type: 'POST',
url:
'users_row.php',
data: {id:id},
dataType: 'json',
success: function(response){
$('.userid').val(response.id);
$('#edit_email').val(response.email);
$('#edit_password').val(response.password);
$('#edit_firstname').val(response.firstname);
$('#edit_lastname').val(response.lastname);
$('#edit_address').val(response.address);
$('#edit_contact').val(response.contact_info);
$('.fullname').html(response.firstname+' '+response.lastname);
}
});
}
</script>
</body>
</html>

CATEGORY
<? ADD
php

include

'includes/session.php';

if(isset($_POST['add'])){
$name = $_POST['name'];

$conn = $pdo->open();

$stmt = $conn->prepare("SELECT *, COUNT(*) AS numrows FROM category


WHERE
name=:name");
4 Page 62

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE
$stmt->execute(['name'=>$name]);
$row = $stmt->fetch();

if($row['numrows'] > 0){

4 Page 63

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE

$_SESSION['error'] = 'Category already exist';


}
else{
try{
$stmt = $conn->prepare("INSERT INTO category (name)
(:name)"); VALUES

$stmt->execute(['name'=>$name]);
$_SESSION['success'] = 'Category added successfully';
}
catch(PDOException $e){
$_SESSION['error'] = $e->getMessage();
}
}

$pdo->close();
}
else
{ $_SESSION['error'] = 'Fill up category form first';

header('location: category.php');

?>

CATEGORY
<? EDIT
php

include

'includes/session.php';

if(isset($_POST['edit'])){
$id = $_POST['id'];
$name = $_POST['name'];

try{
$stmt = $conn->prepare("UPDATE category SET name=:name WHERE
id=:id");
4 Page 64

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE
$stmt->execute(['name'=>$name, 'id'=>$id]);
$_SESSION['success'] = 'Category updated successfully';
}
catch(PDOException $e){
$_SESSION['error'] = $e->getMessage();

4 Page 65

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE

$pdo->close();
}
else
{ $_SESSION['error'] = 'Fill up edit category form first';

header('location: category.php');

?>

5 Page 66

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE

SCREENSHOTS
HOMEPAGE

SIGNUP FROM USER SIDE

5 Page 67

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE

CATEGORY LIST

PRODUCT LIST

5 Page 68

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE

PRODUCT LIST

PRODUCT LIST

5 Page 69

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE

PRODUCT LIST

CART

5 Page 70

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE

ACCOUNT UPDATE

TRANSACTION DETAILS

5 Page 71

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE

SALES HISTORY

USERS DETAIL

5 Page 72

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE

PRODUCT LIST EDIT

CATEGORY LIST EDIT

5 Page 73

Downloaded by Parth Sharma ([email protected])


lOMoARcPSD|51426956

E-COMMERCE DATABASE

CONCULSION
To conclude the description about the project: The
project, developed using PHP and MySQL is
based on the requirement specification of the user
and the analysis of the existing system, with
flexibility for future enhancement. The expanded
functionality of today’s software requires an
appropriate approach towards software
development. This ecommerce software is
designed E- commerce site project is developed
using PHP, CSS, Bootstrap, and JavaScript.
Talking about the project, it has all the required
essential features. This project has a user side
where he/she can view product category and add
products to cart and proceed for checkout whereas
from administration side he/she can view sales,
number of product, users, daily sales report, add
product and categories. The user can also leave
comments on each product if he/she wants. In this
project, all the main functions are performed from
the Admin side User Friendly.

5 Page 74

Downloaded by Parth Sharma ([email protected])

You might also like