-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgetshipaddr.php
106 lines (102 loc) · 4.12 KB
/
getshipaddr.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
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
<?php
include_once ('./config.php');
$con=mysqli_connect($servername,$username,$password,$dbname);
if (mysqli_connect_errno())
{
echo 'Failed to connect to MySQL: ' . mysqli_connect_error();
}
if(isset($_COOKIE['UID']))
{
$userid= $_COOKIE['UID'];
$query="select * from team_best_rds.tbl_shipping_address where userID = $userid";
$result = $con->query($query);
$row = mysqli_fetch_array($result);
if(isset($_GET['action']))
{
if($_GET['action']=='remove')
{
$shipid=$_GET['code'];
$query="UPDATE tbl_shipping_address set deleted = 1 where saddrID = $shipid and userID=$userid";
$con->query($query);
echo'
window.location.href = "shipaddr.php"';
}
elseif($_GET['action']=='edit')
{
//$query="DELETE from team_best_rds.tbl_orderdetails where orderID = $orderID";
//$con->query($query);
echo'
window.location.href = "editshipaddr.php"';
}
}
//get info
$query="select * from team_best_rds.tbl_shipping_address where userID = $userid and deleted = 0";
$result = $con->query($query);
echo '
<div id="shopping-cart" style="margin-top: 60px;">
<div class="txt-heading"><Strong>Manage Shipping Address</strong></div>
<table cellpadding="10" cellspacing="1">
<tbody>
<tr>
<th style="text-align:left;"><h4>Address</h4></th>
<th style="text-align:left;"><h4>City</h4></th>
<th style="text-align:center;"><h4>State</h4></th>
<th style="text-align:center;"><h4>Zip Code</h4></th>
<th style="text-align:center;"></th>
<th style="text-align:center;"></th>
<th style="text-align:center;"></th>
</tr> ';
while($row = mysqli_fetch_array($result))
{
$add1and2 = $row["address1"]." ".$row["address2"];
echo '<tr>
<td style="text-align:left;border-bottom:#F0F0F0 1px solid;">'.$add1and2.'</td>
<td style="text-align:left;border-bottom:#F0F0F0 1px solid;">'.$row["city"].'</td>
<td style="text-align:center;border-bottom:#F0F0F0 1px solid;">'.$row["state"].'</td>
<td style="text-align:center;border-bottom:#F0F0F0 1px solid;">'.$row["zip_code"].'</td>
<td style="text-align:center;border-bottom:#F0F0F0 1px solid;"><a href="shipaddr.php?action=edit&code='.$row["saddrID"].'" class="btnRemoveAction">Edit Shipping Address</a></td>
<td style="text-align:center;border-bottom:#F0F0F0 1px solid;"><a href="shipaddr.php?action=remove&code='.$row["saddrID"].'" class="btnRemoveAction">Delete Shipping address</a></td>
</tr></div>';
}
echo '
<tr>
<td style="text-align:left;border-bottom:#F0F0F0 1px solid;">
<input name = "Address" type = "text" placeholder="Address (Street Name)">
</td>
<td style="text-align:left;border-bottom:#F0F0F0 1px solid;">
<input name = "City" type = "text" placeholder="City">
</td>
<td style="text-align:center;border-bottom:#F0F0F0 1px solid;">
<input name = "State" type = "text" placeholder ="e.g. PA">
</td>
<td style="text-align:center;border-bottom:#F0F0F0 1px solid;">
<input name = "ZipCode" type = "text" placeholder ="e.g. 16803">
</td>
<td style="text-align:center;border-bottom:#F0F0F0 1px solid;">
<input type = "submit" value = "Add New">
</td>
<td style="text-align:left;border-bottom:#F0F0F0 1px solid;">
</td>
</tr>
</div>
</tbody>
</table>
</div>';
}
else{
echo'<script>
function myFunction() {
var r = confirm("Please Log In or Register to access this page!");
if (r == true) {
window.location.href = "login.php";
} else {
window.location.href = "index.php";
}
}
</script>
<script type="text/javascript">
myFunction();
</script>'
;
}
?>