-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathset_def.php
More file actions
41 lines (38 loc) · 989 Bytes
/
set_def.php
File metadata and controls
41 lines (38 loc) · 989 Bytes
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
<?php
require 'connection.php';
require 'current_page.php';
if(loggedin()){
$id = mysql_real_escape_string($_GET['id']);
$user = $_SESSION['user_id'];
$i = 0;
$j = 0;
$k = 0;
$query1 = "UPDATE `address` SET `def`='2' WHERE `userid`='$user' AND `def`='1'";
$query2 = "UPDATE `address` SET `def`='1' WHERE `userid`='$user' AND `aid`='$id'";
$query3 = "UPDATE `address` SET `def`='0' WHERE `userid`='$user' AND `def`='2'";
if($query_run = mysql_query($query1)){
// echo " Default address changed ";
$i = 1;
}else{
echo 'Code 1: could not change default address ';
$i = 0;
}
if($query_run = mysql_query($query2)){
$j = 1;
}else{
echo 'Code 2: could not change default address ';
$j = 0;
}
if($query_run = mysql_query($query3)){
$k = 1;
}else{
echo 'Code 3: could not change default address ';
$k = 0;
}
if($i == 1 && $j == 1 && $k == 1){
echo " Default address changed successfully. Please reload the page to see changes. ";
}else{
echo " An error occurred ";
}
}
?>