<?
include "mysqlcon.php";
if(isset($_GET['u'])) { $u = $_GET['u']; } else { exit; }
if(isset($_GET['u_id'])) { $u_id = $_GET['u_id']; } else { exit; }
if(mysql_num_rows(mysql_query("SELECT * FROM ims WHERE u_id='$u_id' AND new_email_id='$u'")) != 1) { exit; }

$admin_info = mysql_fetch_assoc(mysql_query("SELECT * FROM ims_admin"));
$user_info = mysql_fetch_assoc(mysql_query("SELECT * FROM ims WHERE u_id='$u_id' AND new_email_id='$u'"));

if((time()-(24*60*60))>$user_info[new_email_time] | $user_info[new_email] == "" | $user_info[new_email_time] == "" | $user_info[new_email_id] == "") {
echo "You may not access this page.";
exit;
}

mysql_query("UPDATE ims SET email='$user_info[new_email]',new_email_id='',new_email='',new_email_time='' WHERE u_id='$u_id' AND new_email_id='$u'");

$n = basename($_SERVER['PHP_SELF']);

include "functions.php";
include "vars.php";
echo $header;
echo "
<table cellpadding='0' cellspacing='0' width='520'>
<tr><td>
<b>Email Change Successful</b><br>
Your email has successfully been changed from $user_info[email] to $user_info[new_email].
<br><br>
<b><a href='login.php'>Click here</a> to login to your account.</b>
</td></tr></table>
";
echo $footer;

?>