Skip to content

Commit

Permalink
Created Demo Shopping Cart
Browse files Browse the repository at this point in the history
  • Loading branch information
rasansmn committed Sep 3, 2017
0 parents commit 2e88743
Show file tree
Hide file tree
Showing 27 changed files with 2,438 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
User Login:
[email protected]
password-684684

Admin URL: /admin
Admin Login:
[email protected]
password-684684
204 changes: 204 additions & 0 deletions SQL Dump/demo_cart_db.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
-- phpMyAdmin SQL Dump
-- version 4.2.11
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Oct 23, 2015 at 06:20 AM
-- Server version: 5.6.21
-- PHP Version: 5.6.3

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;

--
-- Database: `demo_cart_db`
--
CREATE DATABASE IF NOT EXISTS `demo_cart_db` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
USE `demo_cart_db`;

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

--
-- Table structure for table `tbladmin`
--

DROP TABLE IF EXISTS `tbladmin`;
CREATE TABLE IF NOT EXISTS `tbladmin` (
`aid` int(11) NOT NULL,
`username` varchar(50) NOT NULL,
`address` varchar(250) NOT NULL,
`email` varchar(100) NOT NULL,
`password` varchar(100) NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbladmin`
--

INSERT INTO `tbladmin` (`aid`, `username`, `address`, `email`, `password`) VALUES
(1, 'rasan samarasinghe', 'embilipitiya', '[email protected]', '6cdbb7905af35b58860fc9a7a34d1cf3');

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

--
-- Table structure for table `tblcart`
--

DROP TABLE IF EXISTS `tblcart`;
CREATE TABLE IF NOT EXISTS `tblcart` (
`cid` int(11) NOT NULL,
`uid` int(11) NOT NULL,
`pid` int(11) NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;

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

--
-- Table structure for table `tblorder`
--

DROP TABLE IF EXISTS `tblorder`;
CREATE TABLE IF NOT EXISTS `tblorder` (
`oid` int(11) NOT NULL,
`time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`price` float NOT NULL,
`creditcno` int(11) NOT NULL,
`address` varchar(250) NOT NULL,
`valid` varchar(10) NOT NULL DEFAULT 'No',
`uid` int(11) NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;

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

--
-- Table structure for table `tblorderitem`
--

DROP TABLE IF EXISTS `tblorderitem`;
CREATE TABLE IF NOT EXISTS `tblorderitem` (
`oiid` int(11) NOT NULL,
`pid` int(11) NOT NULL,
`oid` int(11) NOT NULL,
`uid` int(11) NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;

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

--
-- Table structure for table `tblproduct`
--

DROP TABLE IF EXISTS `tblproduct`;
CREATE TABLE IF NOT EXISTS `tblproduct` (
`pid` int(11) NOT NULL,
`productname` varchar(50) NOT NULL,
`description` varchar(250) NOT NULL,
`imgurl` varchar(100) NOT NULL,
`price` float NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;

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

--
-- Table structure for table `tbluser`
--

DROP TABLE IF EXISTS `tbluser`;
CREATE TABLE IF NOT EXISTS `tbluser` (
`uid` int(11) NOT NULL,
`username` varchar(50) NOT NULL,
`address` varchar(250) DEFAULT NULL,
`email` varchar(100) NOT NULL,
`password` varchar(100) NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbluser`
--

INSERT INTO `tbluser` (`uid`, `username`, `address`, `email`, `password`) VALUES
(1, 'rasan samarasinghe', 'Embilipitiya', '[email protected]', '6cdbb7905af35b58860fc9a7a34d1cf3');

--
-- Indexes for dumped tables
--

--
-- Indexes for table `tbladmin`
--
ALTER TABLE `tbladmin`
ADD PRIMARY KEY (`aid`);

--
-- Indexes for table `tblcart`
--
ALTER TABLE `tblcart`
ADD PRIMARY KEY (`cid`);

--
-- Indexes for table `tblorder`
--
ALTER TABLE `tblorder`
ADD PRIMARY KEY (`oid`);

--
-- Indexes for table `tblorderitem`
--
ALTER TABLE `tblorderitem`
ADD PRIMARY KEY (`oiid`);

--
-- Indexes for table `tblproduct`
--
ALTER TABLE `tblproduct`
ADD PRIMARY KEY (`pid`);

--
-- Indexes for table `tbluser`
--
ALTER TABLE `tbluser`
ADD PRIMARY KEY (`uid`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `tbladmin`
--
ALTER TABLE `tbladmin`
MODIFY `aid` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT for table `tblcart`
--
ALTER TABLE `tblcart`
MODIFY `cid` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT for table `tblorder`
--
ALTER TABLE `tblorder`
MODIFY `oid` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT for table `tblorderitem`
--
ALTER TABLE `tblorderitem`
MODIFY `oiid` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT for table `tblproduct`
--
ALTER TABLE `tblproduct`
MODIFY `pid` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT for table `tbluser`
--
ALTER TABLE `tbluser`
MODIFY `uid` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=2;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
50 changes: 50 additions & 0 deletions about.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<!--
"Demo Shopping Cart" is a non comprehensive e-commerce website developed only for academic purposes. This is just a demonstration of a simple shopping cart and it may contain bugs and errors.

Design and development by Rasan Samarasinghe. (c) 2015 All Rights Reserved.
-->
<?php

include "core.php";

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>About</title>
<link href="styles/style.css" rel="stylesheet" type="text/css" />
</head>

<body>
<div class="page">
<div class="header">
<?php

showHeading();

?>
</div>
<div class="wrapper">
<div class="navigation">
<?php

mainMenu();

?>
</div>
<div class="contents">
<h2>About Us</h2>
<p>"Demo Shopping Cart" is a non comprehensive e-commerce website developed only for academic purposes. This is just a demonstration of a simple shopping cart and it may contain bugs and errors.</p>
</div>
</div>
<div class="footer">
<?php

showFooter();

?>
</div>
</div>
</body>
</html>
105 changes: 105 additions & 0 deletions admin/addadmin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<!--
"Demo Shopping Cart" is a non comprehensive e-commerce website developed only for academic purposes. This is just a demonstration of a simple shopping cart and it may contain bugs and errors.

Design and development by Rasan Samarasinghe. (c) 2015 All Rights Reserved.
-->
<?php

include "../core.php";
include "../dbconnection.php";

//if user not logged in, redirec to login page
if(!isset($_SESSION['aid'])){
header("Location: login.php");
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Add Admin</title>
<link href="../styles/style.css" rel="stylesheet" type="text/css" />
<script src="../js/myscript.js" language="javascript" type="text/javascript"></script>
</head>

<body>
<div class="page">
<div class="header">
<?php

showHeading();

?>
</div>
<div class="wrapper">
<div class="navigation">
<?php

adminMenu();

?>
</div>
<div class="contents">
<h2>Add Admin</h2>
<?php
if($_SERVER['REQUEST_METHOD'] == "POST"){
$username = validateInput($_POST['txtName']);
$address = validateInput($_POST['txtAddress']);
$email = validateInput($_POST['txtEmail']);
$password = validateInput($_POST['txtPassword']);

$stmt = $con->prepare("INSERT INTO tbladmin (username, address, email, password) VALUES (?, ?, ?, ?)");
$stmt->bind_param("ssss", $username, $address, $email, md5($password)); //password hash md5
if($stmt->execute()){
echo "Admin added successfully!<br/>";
}else{
echo "Admin adding failed<br/>";
}
}
?>
<form id="form1" name="form1" method="post" action="addadmin.php" onsubmit="return validateRegister()">
<p>
<label>Name:
<br />
<input name="txtName" type="text" id="txtName" />
</label>
</p>
<p>
<label>Address:<br />
<input name="txtAddress" type="text" id="txtAddress" />
</label>
</p>
<p>
<label>Email:
<br />
<input name="txtEmail" type="text" id="txtEmail" />
</label>
</p>
<p>
<label>Password: <br />
<input name="txtPassword" type="password" id="txtPassword" />
</label>
</p>
<p>
<label>Confirm Password:
<br />
<input name="txtConfPassword" type="password" id="txtConfPassword" />
</label>
</p>
<p>
<input type="submit" name="Submit" value="Submit" />
</p>
</form>
</div>
</div>
<div class="footer">
<?php

showFooter();

?>
</div>
</div>
</body>
</html>
Loading

0 comments on commit 2e88743

Please sign in to comment.