-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathchange_email_script.php
More file actions
30 lines (24 loc) · 1.02 KB
/
Copy pathchange_email_script.php
File metadata and controls
30 lines (24 loc) · 1.02 KB
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
<?php
require_once 'server.php';
require 'signedIn.php';
$currEmail = $_POST['curremail'];
$pword = $_POST['pword'];
$newEmail = $_POST['newemail'];
$cfEmail = $_POST['rnewemail'];
$newPword_query = "SELECT * FROM User_Accounts WHERE user_email = '$currEmail' AND acc_password = '$pword'";
$verify = mysqli_query($trConnect,$newPword_query) or die(mysqli_connect_error());
$user_account = mysqli_num_rows($verify);
if (($user_account == 1) && ($newEmail == $cfEmail)) {
// updates email in db if two emails match
$emailChange = "UPDATE User_Accounts SET user_email = '$newEmail' WHERE user_email = '$currEmail'";
mysqli_query($trConnect, $emailChange);
$_SESSION['email'] = $newEmail;
// redirects them to page saying password has been successfully changed
$success = "change_email_success.php";
header('Location: '.$success);
} else {
// redirects them to page saying they couldnt change email
$fail = "change_email_fail.php";
header('Location: '.$fail);
}
?>