-
Notifications
You must be signed in to change notification settings - Fork 0
/
buy1.php
70 lines (60 loc) · 1.33 KB
/
buy1.php
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
<?php
session_start();
if(isset($_SESSION["memb"]))
{
$user='root';
$pass='';
$db='tupperware';
$con = new mysqli('localhost',$user,$pass,$db) or die("sorry");
$uname=$_SESSION["uname"];
$qty1=$_POST['qty1'];
$qtyx=0;
$qtyy=0;
$query = mysqli_query($con,"SELECT * FROM cart WHERE uname='".$uname."'");
while($row = mysqli_fetch_array($query))
{
$qtyx=$row['item1'];
}
$qtyy = $qty1 + $qtyx;
mysqli_query($con,"update cart set item1='$qtyy' WHERE uname='$uname'");
$query2 = mysqli_query($con,"SELECT * FROM cart WHERE uname='".$uname."'");
$item1=0;
$item2=0;
$item3=0;
$item4=0;
$item5=0;
$item6=0;
$item7=0;
$item8=0;
$item9=0;
$item10=0;
$item11=0;
$item12=0;
$cost=0;
$cost2=0;
while($row = mysqli_fetch_array($query2))
{
$item1=$row['item1'];
$item2=$row['item2'];
$item3=$row['item3'];
$item4=$row['item4'];
$item5=$row['item5'];
$item6=$row['item6'];
$item7=$row['item7'];
$item8=$row['item8'];
$item9=$row['item9'];
$item10=$row['item10'];
$item11=$row['item11'];
$item12=$row['item12'];
$cost=$row['cost'];
}
$cost2 = $item1*200+$item2*390+$item3*250+$item4*280+$item5*450+$item6*350+$item7*200+$item8*180+$item9*250+$item10*270+$item11*410+$item12*330;
mysqli_query($con,"UPDATE cart SET cost='$cost2' WHERE uname='".$uname."'");
mysqli_close($con);
header('Location: portfolio.php');
}
else
{
header('Location: index.html');
}
?>