|
reSIProcate/repro
9694
|
00001 <?php 00002 require('reprofunctions.php'); 00003 dbgSquirt("============= Update Email ==============="); 00004 00005 // check that the user has authenticated 00006 $result = checkCookies($forceLogin,$error,FALSE); 00007 if (!($result) || $forceLogin) { 00008 // we got an error back that occurred while checkCookies was being run, 00009 // or authentication failed. Either way, bounce them back to the login screen 00010 dbgSquirt("Authentication failed"); 00011 header("Location: http://" . $_SERVER['HTTP_HOST'] . 00012 dirname($_SERVER['PHP_SELF']) . 00013 "/index.php?error=$error"); 00014 exit; 00015 } 00016 $username = $_COOKIE['user']; 00017 00018 // check if we got to this page due to a submit or a cancel 00019 dbgSquirt("Checking for cancel"); 00020 if ("Cancel" == $_POST['submit']) { 00021 dbgSquirt("...cancel"); 00022 header("Location: http://" . $_SERVER['HTTP_HOST'] . 00023 dirname($_SERVER['PHP_SELF']) . 00024 "/userhome.php"); 00025 exit; 00026 } 00027 00028 00029 // verify that a new email was provided via POST 00030 dbgSquirt("Checking post"); 00031 if (!isset($_POST['newemail'])) { 00032 // error .. no post variable provided ... possibly because they've jumped 00033 // directly to this page? 00034 dbgSquirt("...not set"); 00035 header("Location: http://" . $_SERVER['HTTP_HOST'] . 00036 dirname($_SERVER['PHP_SELF']) . 00037 "/changeemail.php?error=No new email was provided. Please enter one and click Save. If this error reoccurs, contact an administrator."); 00038 exit; 00039 } 00040 00041 // verify that the new email is non-blank 00042 $newEmail = $_POST['newemail']; 00043 dbgSquirt("Checking blank -- $newEmail"); 00044 if (empty($newEmail)) { 00045 // error ... requested email is blank... bounce them back to change email page 00046 dbgSquirt("...Empty"); 00047 header("Location: http://" . $_SERVER['HTTP_HOST'] . 00048 dirname($_SERVER['PHP_SELF']) . 00049 "/changeemail.php?error=The new email must not be blank."); 00050 exit; 00051 } 00052 00053 // update the email for this user with the provided value 00054 if (updateEmail($username,$newEmail)) { 00055 // update successful 00056 $title = "Email changed"; 00057 $heading = "Email changed"; 00058 $msg = "Email changed to <em>$newEmail</em>."; 00059 } else { 00060 // update failed 00061 $title = "Error while changing email"; 00062 $heading = "Error while changing email"; 00063 $msg = "An error occurred while attempting to change your email. Please contact an administrator."; 00064 } 00065 ?> 00066 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 00067 00068 <!-- 00069 System: Repro 00070 File: updatefilename.php 00071 Purpose: Check permissions, verify requested change, and update email 00072 Author: S. Chanin 00073 --> 00074 <html> 00075 <head> 00076 <link rel="stylesheet" type="text/css" href="repro_style.css" /> 00077 <title><?php echo $title; ?></title> 00078 </head> 00079 00080 <body> 00081 <h1 class="title">Repro</h1> 00082 <h1><?php echo $heading; ?></h1> 00083 <hr /> 00084 <p><?php echo $msg; ?></p> 00085 <br /><hr /> 00086 <a href="userhome.php">Return to User Home</a><br /> 00087 <a href="logout.php">Logout</a><br /> 00088 00089 </body> 00090 </html>
1.7.5.1