Update user email function in PHP

Member

vivien_maggio

by vivien_maggio , in category: PHP , 2 months ago

Update user email function in PHP 😁

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
$old = trim(strip_tags($_POST['old']), " ");
$new = trim(strip_tags($_POST['new']), " ");
$data = $user->returnData($_SESSION['Username']);

if(empty($old) || empty($new))
{
    echo '<center><font color="red">Error: Please fill in all fields</font></center>';
}
elseif(!filter_var($old, FILTER_VALIDATE_EMAIL) || !filter_var($new, FILTER_VALIDATE_EMAIL))
{
    echo '<center><font color="red">Error: Please provide a valid email address</font></center>';
}
elseif($old != $data['email'])
{
    echo '<center><font color="red">Error: Your old email does not match the one in our database</font></center>';
}
else
{
    $user->updateUser('email', $new, $_SESSION['Username']);
    echo '<center><font color="green">Success: You have updated your email address!</font></center>';
    header('Refresh: 3; url=usercp.php');
}


Facebook Twitter LinkedIn Telegram Whatsapp Pocket

no answers