-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathedit.php
80 lines (66 loc) · 3.48 KB
/
edit.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
<?php
session_start();
include('SQL_connection.php');
if (isset($_POST['update'])){
$username = $_POST['username'];
$email = $_POST['email'];
$psw = $_POST['psw'];
$againpsw = $_POST['againpsw'];
if($username != "" || $email != "" || $psw != "" || $againpsw != ""){
$query1 = "SELECT * from accounts where Username='$username'";
$resultusername = mysqli_query($link,$query1);
$numusername = mysqli_num_rows($resultusername);
if($numusername == "" || $numusername == 0){
if($email == "" || filter_var($email,FILTER_VALIDATE_EMAIL)){
$query2 = "SELECT * from accounts where Email='$email'";
$resultemail = mysqli_query($link,$query2);
$numemail = mysqli_num_rows($resultemail);
if($numemail == 0){
$y = $_SESSION['user'];
$tempquery = "SELECT idaccounts from accounts where Username='$y'";
$tempresult = mysqli_query($link,$tempquery);
while($row = mysqli_fetch_array($tempresult)){
$myid = $row['idaccounts'];
}
if(($psw == "" && $againpsw == "") || $psw == $againpsw){
if($email != ""){
$qemail = "UPDATE accounts SET Email='$email' WHERE idaccounts= $myid ";
mysqli_query($link,$qemail);
}
if($username != ""){
$qusername = "UPDATE accounts SET Username='$username' WHERE idaccounts= $myid";
mysqli_query($link,$qusername);
}
if($psw != ""){
$qpsw = "UPDATE accounts SET Mypasssword='$psw' WHERE idaccounts= $myid ";
mysqli_query($link,$qpsw);
}
echo '<script>alert("Your profile has been updated successfully!")</script>';
echo "<script> location.href='login.php'; </script>";
}else{
echo '<script>alert("Passwords did not match. Please try again !")</script>';
echo "<script> location.href='profile.php'; </script>";
exit;
}
}else{
echo '<script>alert("This email allready exists, please use an other.")</script>';
echo "<script> location.href='profile.php'; </script>";
exit;
}
}else{
echo '<script>alert("Invalid email format. Please try again !")</script>';
echo "<script> location.href='profile.php'; </script>";
exit;
}
}else{
echo '<script>alert("This username allready exists, please use an other.")</script>';
echo "<script> location.href='profile.php'; </script>";
exit;
}
}else{
echo '<script>alert("Your profile has nothing to update!")</script>';
echo "<script> location.href='profile.php'; </script>";
}
mysqli_close($link);
}
?>