-
Notifications
You must be signed in to change notification settings - Fork 0
/
ea.php
43 lines (34 loc) · 1.01 KB
/
ea.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
<?php
session_start();
if (!isset($_SESSION['loggedin'])) {
echo '<script>alert("You must sign in as an admin!")</script>';
header("refresh:0.1; url=sign_in.php");
exit();
}
?>
<?php
$oe = $_POST['old_email'];
$ne = $_POST['new_email'];
$np = $_POST['password'];
$conn = mysqli_connect("localhost", "root", "123456", "nozuonodie");
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "UPDATE `account` SET ";
$sql2 = "UPDATE `cart` SET `email` = '$ne' WHERE email = '$oe'";
if(strlen($ne) > 0){
$sql = $sql."`email` = '".$ne."'";
$conn->query($sql2);
}
if(strlen($np) > 0){
if(strlen($ne) > 0){
$sql = $sql.", ";
}
$sql = $sql."`password` = '".$np."'";
}
$sql = $sql." WHERE email = '".$oe."';";
if(strlen($ne) > 0 OR strlen($np) > 0){
$conn->query($sql);
}
header('Location: http://localhost/nozuonodie_back/account.php');
?>