Sunteți pe pagina 1din 17

TE COMPUTERS: 2011 Advanced Database and Web Engineering Project Jonathan Pimento- 45 Sudha Gupta- 17 Kevin Aloysius- 22

PROBLEM STATEMENT CHOR BAZAAAR

The main objective of building this project is to demonstrate the use of web engineering and database with connectivity. Our website called ChorBazaar is an ecommerce site that allows customers/users to browse through a product gallery and select a product to purchase. The customer simply fills out a form and invoice is generated. Admin panels have been implemented that allow the administrators to login and modify the content in the database from the front end. In order to allow people to shop at ease and without physically being present at a shop, we have implemented this site that portrays an online shopping store. The user simply navigates from the home page into the product section, where they browse through a series of 4 products (for representational purpose only.) They then select a product and click on BUY. This takes them to a form where they fill out various details and select a mode of payment.nce the details have been entered, they click order and it generates an INVOICE.) They can then proceed to viewing the products again or can choose to leave. For the administrators, there is a login page where they can access the back end via the front end. That is they can modify the various details and tables in the database. They have the right to change, update, and delete database entries. The major advantages of this ecommerce project are: Easy to navigate and user friendly interface. Helps purchase commodities from the comfort of your desk. Dont have to bother about carrying the product, it is delivered to your address. With various payment modes fast transaction can take place. Most importantly, it allows you to sit back at home and make your purchases with minimum effort.

To understand the full working and connections involved, kindly read through the ER Diagram/tables and code that follows.

EER DIAGRAM- CHOR BAZAAR


Cfname Cid
CUSTOMER

Clname

Address State

Phone

City Pincode

Mode of Payment

Email

Status
CONSIGNMENT

Con_id Quantity

TotalCost

Payment

PRODUCTS
Memory Cost Color

Manufacture

Description

Availability

Pr_name

Pr_id

RELATIONAL TABLES- CHOR BAZAAR

Consignment Table

Customer Table

Product Table

HOME PAGE- CHOR BAZAAR This page has been designed using HTML/CSS and jQuery. Most of the content has been laid out using tables and list. jQuery was used to add .

PRODUCT PAGE
All the product pages are directly linked with the database ecommerce/Product Table. Hence all the information about the respective products is retrieved directly from the database entries.

CODE: <?php $db=mysql_connect('localhost','root','') or die('Unable to connect MySQL.Please Check connection parameters'); mysql_select_db('ecommerce'); $query="SELECT * FROM product WHERE Prname='Seagate Plus'"; $result=mysql_query($query)or die(mysql_error()); $rows=mysql_fetch_array($result); $p_name=$rows['Prname']; $p_id=$rows['Pr_id']; $p_man=$rows['Manufacturer']; $p_cost=$rows['Cost']; $p_col=$rows['color']; $p_mem=$rows['Memory'];

$p_des=$rows['description']; $p_qty=$rows['Availability']; ?> . . . <TABLE BORDER="0" WIDTH="600" HEIGHT="10" cellpadding="0"style="backgroundcolor:#ffffff"> <?php print "<TR>"; print "<TD><B>PRODUCT NAME:".($p_name)."</B></TD>"; print "<TD><B>PRODUCT ID:".($p_id)."</B></TD>"; print "</TR>"; print "<TR>"; print "<TR ALIGN=>"; print "<TD><B>MANUFACTURER: </B>".($p_man)."</TD>"; print "<TD><B>COST:</B>". ($p_cost)."</TD>"; print "</TR ALIGN='LEFT'>"; print "<TR>"; print "<TD><B>COLOR: </B>"; print $p_col. " </TD>"; print "<TD><B>MEMORY: </B>".($p_mem)."</TD>"; print "</TR>"; print "<TR>"; print "<TD ><B>DESCRIPTION</B>"; print "<BR>"; print ($p_des); print "</TD>"; if($p_qty==0) {print "<TD><B>STOCK: </B>Out Of Stock!! Sorry</TD>";} else {print "<TD><B>STOCK: </B>Available:".($p_qty)."</TD>"; } print "</TR>"; mysql_close(); ?> </TABLE>

PURCHASE FORM

The Purchase form is used to collect the customer Information and other informations regarding the purchase. All of which is inserted into the database/Customer Table, Consignment Table and Product table.

CODE: <?php $con= mysql_connect("localhost","root",""); mysql_select_db('ecommerce'); $sql="INSERT INTO Customer(Cfname,Clname,Address,State,City,Pincode,Email_id,Phone,Mode_of_payment) VALUES('$_POST[ad]','$_POST[x1]','$_POST[TXTADDRESS]','$_POST[x]','$_POST[CMBSTATE]','$_ POST[x2]','$_POST[x3]','$_POST[xq]','$_POST[payment]')"; $sql1="INSERT INTO Consignment(Cfname,Clname,Prname,Quantity,Payment)VALUES('$_POST[ad]','$_POST[x1]','$_ POST[x5]','$_POST[qty]','$_POST[payment]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); }

if (!mysql_query($sql1,$con)) { die('Error: ' . mysql_error()); }

mysql_close($con) ?>

INVOICE PAGE

For printing the Invoice Page, consignment information from the Customer and Consignment table is retrieved. Also the total cost of the products is calculated and updated in the Consignment table. The no. of products a customer buys is deducted from the Availability attribute of the Product table.

CODE: <?php $db=mysql_connect('localhost','root','') or die('Unable to connect MySQL.Please Check connection parameters'); mysql_select_db('ecommerce'); $query="SELECT * FROM consignment where Cfname='$_POST[ad]' and Clname='$_POST[x1]'"; $result=mysql_query($query) or die(mysql_error()); $rows=mysql_fetch_array($result); $cu_id=$rows['Con_id']; $cu_fname=$rows['Cfname']; $cu_lname=$rows['Clname']; $cu_product=$rows['Prname']; $cu_quantity=$rows['Quantity']; $cu_payment=$rows['Payment']; $query1="SELECT * FROM product where Prname='$_POST[x5]' "; $r=mysql_query($query1) or die(mysql_error()); $row=mysql_fetch_array($r); $cost=$row['Cost']; $pqty=$row['Availability']; $tot= $cost * $cu_quantity; // Total Cost is calculated $new_qty=$pqty - $cu_quantity; // No. of products being decremented $upc="UPDATE Consignment SET TotalCost = ($tot) WHERE Cfname='$_POST[ad]' and Clname='$_POST[x1]'"; // the new value of Availability attribute being updated $up="UPDATE product SET Availability = ($new_qty) WHERE Prname = '$_POST[x5]'"; mysql_query($upc) or die (mysql_error()); mysql_query($up) or die (mysql_error()); ?> // DISPLAYING THE INVOICE <b><h3>Thank You For Shopping with Us !! Please print the Invoice</h3></b></MARQUEE> <FONT FACE= "Arial" color=#000000> <?php print "<b><H1>".("INVOICE")."</H1></b>"; print "<br><br><br>"; print "<br><br><br>"; print "<b>&nbsp;&nbsp;".("Consignment ID:")."</b>"; print ($cu_id)."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"; print "<b>".("Customer Name:")."</b>"; print($cu_fname); print (" "); print($cu_lname)."<br/>"; print "<br>"; print "<b>".("Product Name:")."</b>"; print($cu_product)."&nbsp&nbsp&nbsp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"; print "<b>".("Number of Products:")."</b>"; print($cu_quantity)."<br/> <br><br><br><br>"; print "<b>".("Mode of Payment:")."</b> "; print ($cu_payment)."<br>";print "<br><br><br><br><h1><B>Total Cost:".($tot)."</b></h1>";?>

CODE <?php mysql_connect("localhost","root",""); mysql_select_db('ecommerce'); $query="SELECT * FROM consignment"; $result=mysql_query($query) or die(mysql_error()); ?>

<?php while($row=mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" .$row['Con_id']."</td>" ; echo "<td>" .$row['Cfname']."</td>" ; echo "<td>" .$row['Clname']."</td>" ; echo "<td>" .$row['Prname']."</td>" ; echo "<td>" .$row['Quantity']."</td>" ; echo "<td>" .$row['TotalCost']."</td>" ; echo "<td>" .$row['Payment']."</td>" ; echo "</tr>"; } ?>

CODE <?php $con= mysql_connect("localhost","root",""); mysql_select_db('ecommerce'); $sql="INSERT INTO Customer(Cfname,Clname,Address,State,City,Pincode,Email_id,Phone,Mode_of_payment) VALUES('$_POST[ad]','$_POST[x1]','$_POST[TXTADDRESS]','$_POST[x]','$_POST[CMBSTATE]','$_ POST[x2]','$_POST[x3]','$_POST[xq]','$_POST[payment]')";

$sql1="INSERT INTO Consignment(Cfname,Clname,Prname,Quantity,Payment)VALUES('$_POST[ad]','$_POST[x1]','$_ POST[x5]','$_POST[qty]','$_POST[payment]')";

if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); }

if (!mysql_query($sql1,$con)) { die('Error: ' . mysql_error()); }

mysql_close($con) ?> <?php $db=mysql_connect('localhost','root','') or die('Unable to connect MySQL.Please Check connection parameters');

mysql_select_db('ecommerce'); $query="SELECT * FROM consignment where Cfname='$_POST[ad]' and Clname='$_POST[x1]'"; $result=mysql_query($query) or die(mysql_error()); $rows=mysql_fetch_array($result); $cu_id=$rows['Con_id']; $cu_fname=$rows['Cfname']; $cu_lname=$rows['Clname']; $cu_product=$rows['Prname']; $cu_quantity=$rows['Quantity']; $cu_payment=$rows['Payment']; $query1="SELECT * FROM product where Prname='$_POST[x5]' "; $r=mysql_query($query1) or die(mysql_error()); $row=mysql_fetch_array($r); $cost=$row['Cost']; $pqty=$row['Availability']; $tot= $cost * $cu_quantity; $new_qty=$pqty - $cu_quantity; $upc="UPDATE Consignment SET TotalCost = ($tot) WHERE Cfname='$_POST[ad]' and Clname='$_POST[x1]'"; $up="UPDATE product SET Availability = ($new_qty) WHERE Prname = '$_POST[x5]'"; mysql_query($upc) or die (mysql_error()); mysql_query($up) or die (mysql_error()); ?>

CODE <?php session_start(); $_SESSION['product_id']=$_POST['inputname']; $db=mysql_connect("localhost","root","") or die('Unable to Connect To Database.Please check the Database Parameters'); mysql_select_db('ecommerce') or die(mysql_error()); $id=$_POST['inputname']; $query="SELECT * FROM product WHERE Pr_id='$_POST[inputname]'"; $result=mysql_query($query) or die(mysql_error()); $row=mysql_fetch_array($result); $name=$row['Prname']; $manu=$row['Manufacturer']; $cost=$row['Cost']; $color=$row['color']; $memory=$row['Memory']; $avail=$row['Availability']; $desc=$row['description']; ?>

<?php session_start(); $db=mysql_connect("localhost","root","") or die('Unable to Connect To Database.Please check the Database Parameters'); mysql_select_db('ecommerce') or die(mysql_error()); $new_name=$_POST['name']; $new_manu=$_POST['manu']; $new_cost=$_POST['cost']; $new_color=$_POST['color']; $new_memory=$_POST['memory']; $new_avail=$_POST['avail']; $new_desc=$_POST['desc']; $id=$_SESSION['product_id'];

$query2="UPDATE product SET Prname='$new_name',Manufacturer='$new_manu',Cost='$new_cost',color='$new_color',Mem ory='$new_memory',Availability='$new_avail',description='$new_desc' WHERE Pr_id='$id'"; mysql_query($query2) or die(mysql_error());

if(mysql_affected_rows()==1) { print("<br>"); print("<h1 align=\"center\">Thank you Administrator The Database Has Been Sucessfully Updated!<img src=\"images/accepted_48.png\"></h1>"); } else print("<h1 align=\"center\">Hey Admin I Think you Made a Glitch...SomeWhere....</h1><br>"); ?>

CONCLUSION:
Thus we have successfully implemented a store front website using HTML/CSS for the front end, MySQL for the backend and PHP for the framework and connectivity.

S-ar putea să vă placă și