-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchangeemail.php
68 lines (62 loc) · 1.9 KB
/
changeemail.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
<?php
require_once 'require/util.php'; //utility functions
require_once 'require/htmllib.php'; //HTML functions
require_once 'require/dblib.php'; //database functions
error_reporting(E_ALL); ///YES! YES! YES!
begin_session();
print_htmlhead('Change Email',0);
if ($_SESSION['authorized']) //yes yes, they are logged in.
{
//Connect to Server
$server = bank_server_connect();
if (!isset($_POST['submitted'])) //was a form submitted
{
print_form($server);
}
else if (isset($_POST['submitted'])) //a form was submitted
{
$password = clean_input($_POST['password']); //clean up input
//Spin that shit!
if (check_password($_SESSION['username'], $password, $server)) //do they know the password?
{
if (email_valid($_POST['email'])) //email format check
{
//a valid email format
set_email($_SESSION['username'], $_POST['email'], $server); //make a change.
print ("Your email has been changed.<br />");
print ("Your current email is: ".get_email($_SESSION['username'], $server)."<br />");
}
else
{
print ("That was not a valid email format!<br />");
}
}
else //lies! They know it not!
{
print ("That is the incorrect password for this account.<br />");
print_form();
}
}
}
else
{
print ("You must <a href='login.php'>login</a> to use this page.<br />");
}
print_htmlfoot();
function print_form($server)
//prints the form for password changes
{
print ("Your current email is: ".get_email($_SESSION['username'], $server)."<br />");
print ('<br />');
print ('<form action="changeemail.php" method="post">');
print ('<br />Confirm Password ');
print ('<input type="password" name="password" value="" />');
print ('<br />New Email ');
print ('<input type="text" name="email" value="[email protected]" />');
print ('<br /><br />');
print ('<input type="hidden" name="submitted" value="true" />');
print ('<input type="submit" value="Change email" />');
print ('</form>');
print ('<br />');
}
?>