E Commerce Database Project Report
E Commerce Database Project Report
E-COMMERCE DATABASE
INTRODUCTION
Page 1
E-COMMERCE DATABASE
OBJECTIVE
Page 2
E-COMMERCE DATABASE
NEEDS OF ECOMMERCE
Page 3
E-COMMERCE DATABASE
E-COMMERCE DATABASE
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
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
E-COMMERCE DATABASE
DATABASE
Page 7
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
E-COMMERCE DATABASE
Figure: ER diagram
Page 9
E-COMMERCE DATABASE
1 Page 10
G-COMMERCE DATABASE
1 Page 11
I-COMMERCE DATABASE
1 Page 12
K-COMMERCE DATABASE
1 Page 13
M-COMMERCE DATABASE
1 Page 14
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
Q-COMMERCE DATABASE
SYSTEM ANALYSIS
Context diagram
Leveled data flow diagrams
Process specification for elementary bubbles
Data dictionary for the flow and stores on the DFDs.
1 Page 16
S-COMMERCE DATABASE
System Design
Implementation
1 Page 17
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
1. General User
2. Registered Users
1 Page 18
E-COMMERCE DATABASE
SOURCE
CODE
LOGIN PAGE
1 Page 19
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
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>
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
E-COMMERCE DATABASE
</div>
";
unset($_SESSION['error']);
}
?>
<div class="login-box-body">
<p class="login-box-msg">Enter new password</p>
RESET
<?
php use PHPMailer\PHPMailer\
PHPMailer; use PHPMailer\
PHPMailer\Exception;
include
'includes/session.php';
2 Page 22
E-COMMERCE DATABASE
ail = $_POST['email'];
i
'
'
{
$
e
m
2 Page 23
E-COMMERCE DATABASE
$conn = $pdo->open();
$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
E-COMMERCE DATABASE
//Content
$mail->isHTML(true);
$mail->Subject = 'ECommerce Site Password Reset';
$mail->Body = $message;
$mail->send();
}
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
E-COMMERCE DATABASE
if(isset($_SESSION['captcha'])){
2 Page 26
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>
2 Page 27
E-COMMERCE DATABASE
</div>
<div class="form-group has-feedback">
2 Page 28
E-COMMERCE DATABASE
VERIFY
<?
php include 'includes/session.php';
$conn = $pdo->open();
if(isset($_POST['login'])){
$email =
$_POST['email'];
$password =
$_POST['password']; try{
E-COMMERCE DATABASE
$row = $stmt->fetch();
2 Page 30
E-COMMERCE DATABASE
} }
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
$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
E-COMMERCE DATABASE
catch(PDOException $e){
echo "There is some problem in connection: " . $e->getMessage();
}
2 Page 32
E-COMMERCE DATABASE
$pdo->close();
?>
<?php include 'includes/header.php'; ?>
<body class="hold-transition skin-blue layout-top-nav">
<div class="wrapper">
<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>$
".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
E-COMMERCE DATABASE
}
2 Page 34
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>
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
E-COMMERCE DATABASE
if($row['numrows'] < 1){
try{
2 Page 36
E-COMMERCE DATABASE
}
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
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
E-COMMERCE DATABASE
$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();
$total = 0;
foreach($stmt as $row)
{
$subtotal = $row['price'] * $row['quantity'];
$total += $subtotal;
}
$pdo->close();
echo json_encode($total);
}
3 Page 39
E-COMMERCE DATABASE
?>
3 Page 40
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">
<div class="content-wrapper">
<div class="container">
$conn = $pdo->open();
$_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
E-COMMERCE DATABASE
href='product.php?product=".$row['slug']."'>".$highlighted."</a></h5>
</div>
<div class='box-footer'>
<b>$
".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>
REGISTER
<?
php use PHPMailer\PHPMailer\
PHPMailer; use PHPMailer\
PHPMailer\Exception;
include
3 Page 42
E-COMMERCE DATABASE
' sset($_POST['signup'])){
$firstname = $_POST['firstname'];
i
'
3 Page 43
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->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
E-COMMERCE DATABASE
password,
3 Page 45
E-COMMERCE DATABASE
$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,
$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
E-COMMERCE DATABASE
unset($_SESSION['firstname'
]);
unset($_SESSION['lastname']
);
3 Page 47
E-COMMERCE DATABASE
unset($_SESSION['email']);
}
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
E-COMMERCE DATABASE
const VERSION =
'php_1.1.2'; private $secret;
3 Page 49
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;
}
REQUEST METHOD
<?php
namespace ReCaptcha;
public function submit(RequestParameters $params);
}
3 Page 50
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
E-COMMERCE DATABASE
return $params;
}
3 Page 52
E-COMMERCE DATABASE
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`
--
-- --------------------------------------------------------
--
4 Page 53
E-COMMERCE DATABASE
--
-- Dumping data for table `category`
--
-- --------------------------------------------------------
--
-- Table structure for table `details`
--
--
-- Dumping data for table `details`
--
-- --------------------------------------------------------
--
-- Table structure for table `products`
--
4 Page 54
E-COMMERCE DATABASE
--
-- 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`
--
--
-- Dumping data for table `sales`
--
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
4 Page 55
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',
--
-- 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
E-COMMERCE DATABASE
--
ALTER TABLE `users`
ADD PRIMARY KEY (`id`);
4 Page 57
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
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">
4 Page 59
E-COMMERCE DATABASE
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
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 -->
4 Page 61
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();
E-COMMERCE DATABASE
$stmt->execute(['name'=>$name]);
$row = $stmt->fetch();
4 Page 63
E-COMMERCE DATABASE
$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
E-COMMERCE DATABASE
$stmt->execute(['name'=>$name, 'id'=>$id]);
$_SESSION['success'] = 'Category updated successfully';
}
catch(PDOException $e){
$_SESSION['error'] = $e->getMessage();
4 Page 65
E-COMMERCE DATABASE
$pdo->close();
}
else
{ $_SESSION['error'] = 'Fill up edit category form first';
header('location: category.php');
?>
5 Page 66
E-COMMERCE DATABASE
SCREENSHOTS
HOMEPAGE
5 Page 67
E-COMMERCE DATABASE
CATEGORY LIST
PRODUCT LIST
5 Page 68
E-COMMERCE DATABASE
PRODUCT LIST
PRODUCT LIST
5 Page 69
E-COMMERCE DATABASE
PRODUCT LIST
CART
5 Page 70
E-COMMERCE DATABASE
ACCOUNT UPDATE
TRANSACTION DETAILS
5 Page 71
E-COMMERCE DATABASE
SALES HISTORY
USERS DETAIL
5 Page 72
E-COMMERCE DATABASE
5 Page 73
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