-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME
157 lines (125 loc) · 4.54 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
Overview:
========
Simple E-Commerce System: a web interface that implements a simple and secure e-commerce system using PHP and MySQL.
Author:
======
Carmine Benedetto
Website: http://www.carminebenedetto.net
Email: carmine.benedetto[at]gmail.com
Used Tools:
==========
- Apache/2.2.22 (Ubuntu)
- MySQL client version: 5.5.24
- PHP extension: mysqli
- phpMyAdmin version: 3.4.10.1deb1
Application Structure:
=====================
index.php
---------
First page of the application. This page shows the store window with products, price and store availability.
The user can Log In if he's already registered or Sign Up if he's not.
Doing the Log In, the user will be redirected to the Store page.
If a User Session is open, all the requests for the Index page will be redirected to the Store page.
Dependencies:
index.php -> Log In -> store.php
index.php -> Sign Up -> register.html
register.html
-------------
User Registration From.
Dependencies:
register.html -> Register -> registration.php
registration.php
----------------
This module gets the user paramters from the Registration Form, performs the appropriate checks and writes the user data in the database (user table).
Dependencies:
registration.php -> index.php
store.php
---------
In this page the user can choose the products he wants to buy. A lateral bar indicates the log status and the cart status.
Dependencies:
store.php -> Add Items to the Cart -> addcart.php
store.php -> Show the Cart -> showcart.php
addcart.php
-----------
This module gets the cart parameters from the Add To Cart Form, performs the appropriate checks and write the cart data in the database (cart table).
At the end of all the operation, the module redirects the user to the Store page.
Dependencies:
addcart.php -> store.php
showcart.php
-----------
This page shows the Cart with products, quantity and total amount of chosen products.
The user can pay for the chosen products (putting the credit card parameters), empty the cart or go back to the store.
Dependencies:
showcart.php -> Checkout -> pay.php
showcart.php -> Empty Cart -> emptycart.php
showcart.php -> store.php
emptycart.php
-------------
This module deletes from the database the data from the cart table for the currently logged on user.
At the end of all the operations, the module redirects the user to the Store page.
Dependencies:
emptycart.php -> store.php
pay.php
-------
This module gets the credit card parameters from the Payment Form, checks if the chosen products are still available on the store and than simulates a payment transation.
The payment transation is performed using a random function.
In case of successful transation, the module empties the cart.
Dependencies:
pay.php -> store.php
LOGOUT
------
It's possible do the Log Out from different pages using the lateral bar.
The Log Out operation redirects the user to the Index page.
Pages:
store.php
showcart.pgp
pay.php
Database Tables:
===============
- products -
------------------------------
| id | item | prize | number |
------------------------------
- id: product id;
- item: product name;
- prize: product price;
- number: product availability.
- users -
--------------------------------------------------------------------
| name | surname | country | address | email | username | password |
--------------------------------------------------------------------
- cart -
----------------------------
| sid | id_item | quantity |
----------------------------
- sid: $_SESSION['username'] (super global variable);
- id_item : product id;
- quantity: item quantity to buy.
- sessions -
-------------------------
| sid | sdata | sexpire |
-------------------------
- sid: session id;
- sdata: session data corresponding with $_SESSION['username'];
- sexpire: session expiration time.
NOTE ABOUT THE CART AND THE SESSION MANAGEMENT:
==============================================
Adding items to the cart the database table product is not modified so the product availability remains unchanged until the successful payment.
In the Session Garbage Collector, a cart connected to a session is deleted if the session expires or if it is destroyed.
ATOMIC OPERATIONS / LOCKS:
=========================
New User Registration
File: registration.php
Locked tables: users(WRITE)
Add items to the cart
File: addcart.php
Locked tables: cart(WRITE)
Empty the cart
File: addcart.php
Locked tables: cart(WRITE)
Payment
File: pay.php
Locked tables: products(WRITE), cart(WRITE)
Session Garbage Collector
File: class_session.php
Locked tables: cart(WRITE), sessions(WRITE)