Dbms Final Report
Dbms Final Report
Project
for
CSE 2004
Database Management Systems
Submitted by:-
YASH AGARWAL-19BEC0599
VARUN GOEL-19BCE2296
AARYASH KANSAL-19BCE0339
To
Prof. Mohan Kumar P
In D2 SLOT
1.Abstract
2.Introduction
3.Problem Definition
5.PHP Code
6.Result
7.Conclusion
1) Abstract:
<?php session_start();
if ($_SERVER["REQUEST_METHOD"] == "POST")
{if
(empty($_POST['username'])||empty($_POST['password'])||empty($_POST['ma
il_id']))
{
header("Location:oops_log_in_1.html");
exit;
}
else {
$servername = "localhost";
$username = "root";
$password = "";
try
{
$name= test_input($_POST['username']);
if(preg_match("/^[a-zA-Z ]*$/",$name))
{$_SESSION['name']=$name; }
else {
header("Location:oops_
log_in_1.html");
exit;
}
$mail_id= test_input($_POST['mail_id']);
if(!filter_var($mail_id, FILTER_VALIDATE_EMAIL))
{
header("Location:oops_log_in_1.html");
exit;
}
else {
$_SESSION['mail_id']=$mail_id;
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$stmt = $conn->prepare("INSERT INTO dba.customer
(username,mail_id,password) VALUES (:username,:mail_id,:password)");
$stmt->bindParam(':username',$username);
$stmt->bindParam(':mail_id',$mail_id);
$stmt->bindParam(':password',$password);
$username = $_SESSION['name'];
$password = test_input($_POST['password'])
$_SESSION['cust_id']=$mail_id
=$_SESSION['mail_id'];
if(isset($_POST['mail_id']))
{$mail_id = $_POST['mail_id']; }
$stmt->execute();
catch(PDOException $e)
{ header("Location:oops_log_in_1.html");
exit;
$conn = null;
}
}
function test_input($data){
echo "hello";
$data=trim($data);
$data=stripslashes($data);
$data=htmlspecialchars($data);
return $data;
}
?>
LOGIN:
<?php session_start();
if ($_SERVER["REQUEST_METHOD"] == "POST"){
if(empty($_POST['mail_id']) || empty($_POST['password']))
{
header("Location: oops_log_in_1.html" );
}
else
{ $mail_id=$_POST['mail_id'];
$pass=$_POST['password'];
$servername='localhost';
$username='root';
$password='';
try{
$conn = new
PDO("mysql:host=$servername;dbname=dba", $username, $password);
$conn-
>setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
$stmt=$conn->prepare("SELECT
username,mail_id,password,num FROM dba.customer WHERE
mail_id='$mail_id' and password='$pass' ");
$stmt->setFetchMode(PDO::FETCH_ASSOC);
$stmt->execute();
$data=$stmt->fetch();
if(($data['mail_id']==$mail_id) &&
($data['password']==$pass)){
$_SESSION['cust_id']=$_SESSION['mail_id']=$mail_id;
$_SESSION['username']=$data['username'];
$num=$data['num'];
$num++;
$_SESSION['num']=$num;
}
else{ header("Location:
oops_log_in_1.html"
);exit();
}
}
catch(PDOException $e)
{
echo $e->getMessage();
$conn=null;
}
}
?>
CART:
<?php session_start();
include "cart.html";
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "dba";
try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username,
$password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$cust_id= $_SESSION['cust_id'];
$num=$_SESSION['num'];
$row = $stmt->fetch();
$invoice_id=$row['invoice_id'];
echo "<h1 style='text-align:center;margin-top:50px;font-
size:50px;'>CART</h1>";
include "continue.php";
include "footer.html";
?>
WISHLIST:
<?php session_start();
include "cart.html";
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "dba";
try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username,
$password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$cust_id= $_SESSION['cust_id'];
}
catch(PDOException $e) {
echo "Error: " . $e->getMessage();
header("Location:cart.php");exit();
}
$conn = null;
include "footer.html";
?>
DELETE CART:
<?php session_start();
if(isset($_POST['delete'])){
$servername = "localhost";
$username = "root";
$password = "";
try
{$pro_id= $_SESSION['pro_id']=$_POST['pro_id'];
$cust_id=$_SESSION['mail_id'];
$num=$_SESSION['num'];
$invoice_id = $row['invoice_id'];
echo $quan;
$stmt = $conn->prepare("DELETE FROM dba.invoice_product WHERE
invoice_id='$invoice_id' AND pro_id='$pro_id' and count='$quan'");
$stmt->execute();
$quan--;$stmt = $conn->prepare("update dba.final_invoice_prod set
quantity='$quan' where invoice_id='$invoice_id' AND pro_id='$pro_id' ");
$stmt->execute();
if ($quan==0){
}
header("Location:cart.php");
exit();
}
catch(PDOException $e)
{
echo $e->getMessage();
//header("Location:cart.php");
//exit();
}
$conn = null;
}
DELETE WISHLIST:
<?php session_start();
if(isset($_POST['delete'])){
$servername = "localhost";
$username = "root";
$password = "";
try
{ $pro_id=$_SESSION['pro_id']=$_POST['pro_id'];
$cust_id=$_SESSION['mail_id'];
//$cust_id=$_SESSION['mail_id'];
//$num=$_SESSION['num'];//$stmt =
$conn->prepare("select invoice_id from dba.invoice
where cust_id='$cust_id' AND num='$num'");
//$stmt->execute();
//$row = $stmt->fetch();
//$_SESSION['invoice_id']=$row['invoice_id'];
header("Location:wishlist.php");exit();
}
catch(PDOException $e)
{
// echo $e->getMessage();
header("Location:wishlist.php");exit();
$conn = null;
?>
$servername = "localhost";
$username = "root";
$password = "";
try
{ $pro_id=$_SESSION['pro_id'];
$stmt->bindParam(':pro_id',$pro_id);
$stmt->bindParam(':cust_id',$cust_id);
$pro_id=$_SESSION['pro_id'];
$cust_id=$_SESSION['mail_id'];
$stmt->execute();
header("Location:final_order.php");exit();
}
catch(PDOException $e)
{
echo $e->getMessage();
header("Location:final_order.php");exit();
$conn = null;
?>
COURIER:
else {
$servername = "localhost";
$username = "root";
$password = "";try
{
$name=
test_input($_POST['recipient_name']);
if(preg_match("/^[a-zA-Z
]*$/",$name))
{$_SESSION['recipient_name']=$name; }
else
{
header("Location:oops_log_in_1.html"); exit;
}
$namea=
test_input($_POST['house
_no']);
]*$/",$namea)) if(preg_match("/^[a-zA-Z
0-9_.-
{$_SESSION['house_no'
]=$namea; }
exit; else
{
header("Location:oops_log_i
n_1.html");
$nameb= test_input($_POST['area']);
if(preg_match("/^[a-zA-Z ]*$/",$nameb))
{$_SESSION['area']=$nameb; }
else {
header("Location:oops
_log_in_1.html");
exit;
}
$namec= test_input($_POST['landmark']);
if(preg_match("/^[a-zA-Z ]*$/",$namec))
{$_SESSION['landmark']=$namec; }
else {
header("Location:oo
ps_log_in_1.html");
exit;
}
$named= test_input($_POST['city']);
if(preg_match("/^[a-zA-Z ]*$/",$named))
{$_SESSION['city']=$named; }
else
{
header("Location:oops
exit; _log_in_1.html");
$namee= test_input($_POST['state']);
if(preg_match("/^[a-zA-Z ]*$/",$namee))
{$_SESSION['state']=$namee; }
else {
header("Location:oops_
log_in_1.html");
exit;
}
$namef= test_input($_POST['phone_no']);
if(preg_match("/[7-9]{1}[0-9]{9}/",$namef))
{$_SESSION['phone_no']=$namef; }
else {
header("Location:oo
ps_log_in_1.html");
exit;
}
$namef= test_input($_POST['pincode']);
if(preg_match("/[0-9]{6}$/",$namef))
{$_SESSION['pincode']=$namef; }
else {
header("Location:oo
ps_log_in_1.html");
exit;
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$stmt->bindParam(':area',$area);
$stmt->bindParam(':landmark',$landmark);
$stmt->bindParam(':city',$city);
$stmt->bindParam(':state',$state);
$stmt->bindParam(':pincode',$pincode);
$stmt->bindParam(':mail_id',$mail_id);
$recipient_name = $_SESSION['recipient_name'];
$phone_no = $_SESSION['phone_no'];
$house_no = $_SESSION['house_no'];
$area = $_SESSION['area'];
$landmark = $_SESSION['landmark'];
$city = $_SESSION['city'];
$state = $_SESSION['state'];
$pincode = $_SESSION['pincode'];
$mail_id=$_SESSION['mail_id'];
$stmt->execute();
header("Location:final_order.php"); exit;
}
catch(PDOException $e)
{ echo "<h1 style='font-size:45px;text-
align:center;margin-top:300px;'>This Address Already Exists</h1>";
exit;
$conn = null;
}
}
function test_input($data){
$data=trim($data);
$data=stripslashes($data);
$data=htmlspecialchars($data);
return $data;
}
?>
If new address:
<?php session_start();$mail_id=$_SESSION['mail_id'];
$servername = "localhost";
$username = "root";
$password = "";
try
{
$conn = new
PDO("mysql:host=$servername;dbname = db",$username,$password);
$conn->setAttribute(PDO::ATTR_ERRMODE,
PDO::ERRMODE_EXCEPTION);
if ($_SERVER["REQUEST_METHOD"] == "POST")
$mail_id=$_SESSION['mail_id'];
$stmt = $conn->prepare("SELECT
recipient_name,phone_no,house_no,area,landmark,city,state,pincode from
dba.courier where mail_id='$mail_id'");
$stmt->execute();
$row = $stmt->fetch();
$_SESSION['recipient_name']=$row['recipient_name'];$_SESSION['house_no'
]=$row['house_no'];$_SESSION['area']=$row['area'];$_SESSION['landmark']
=$row['landmark'];$_SESSION['city']=$row['city'];$_SESSION['state']=$ro
w['state'];$_SESSION['pincode']=$row['pincode'];}
header("Location:final_order.php"); exit;
}
catch(PDOException $e)
{ echo
$e->getMessage();
//header("Location:o
exit; ops_log_in_1.html");
$conn = null;
FINAL CART:<?php session_start(); include "cart.html";
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "dba";
try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username,
$password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$cust_id= $_SESSION['cust_id'];
$num=$_SESSION['num'];
$row = $stmt->fetch();
$invoice_id=$row['invoice_id'];
echo "<h1 style='text-align:center;margin-top:50px;font-
size:50px;'>ORDER</h1><h3 style='text-align:center;margin-
top:50px;font-size:30px;'>PAYMENT CASH ON DELIVERY</h3>";
include "footer.html";
?>
RESULT:
When we open the page:
Log in/ singup:
To view items:
Cart:
Invoice Product:
COURIER:
Final Order
Thank You
Conclusion
Ecommerce Has Made The World A Much Smaller Place,
Thanks To The Internet. It Is Convenient, Fast, And Easy. The
Number Of People Turning To E-shopping Is Only Going To
Rise As Time Goes By. So Make Your Business Go Online.
The Whole World Is Going Online So It Was The Right Step
Taken When We Brought The Shopping World Online. Now
The Person Doesn't Have To Walk Around In The Market
Under Sun And Check For Availability Of A Product. Now
Anyone Can Sit In Their Home And Order Their Goods With
Maximum Comfort.
However, This Project Requires:
• A web browser
• Python
• XAAMP
Strengths of e-Commerce Website:
• Faster buying/selling procedure, as well as easy to find
products.
• Buying/selling 24/7.
• More reach to customers, there are no theoretical geographic
limitations.
• Low operational costs and better quality of services.
• No need for physical company set-ups.
• Easy to start and manage a business.
• Customers can easily select products from different
providers without moving around physically.
Shortcoming of e- Commerce Website:
● Any one, good or bad, can easily start a business. And
there are many bad sites which eat up customers’
money.
● There is no guarantee of product quality.
● Mechanical failures can cause unpredictable
effects on the total processes.
● As there is minimum chance of direct customer to
company interactions, customer loyalty is always on a
check.
● There are many hackers who look for opportunities, and
thus an ecommerce site, service, payment gateways, all
are always prone to attack.
Database Screenshots:
References:
1. www.hotscripts.com/category/php/
2. www.apache.org/
3. www.mysql.com/click.php?e=35050
4. www.w3schools.com
5. in.php.net
6. en.wikipedia.org/wiki/PHP