Location: PHPKode > projects > Echelon - A Writing Center Portal > echelon-1.0.0/resetpasswd.php
<?php
/* resetpasswd.php -- Handles resetting user passwords */

require_once("include/util.php");
require_once("include/user.php");

session_start();
session_destroy();

/* Following snippet of code to prevent caching is from W3Schools.com */
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");	// Date in the past

cleanup_array($_POST);

if (($_GET['action'] == 'reset') && !empty($_POST['username']))
{
	$resetuser = new DO_User();
	if ($resetuser->fill_by_username($_POST['username']))
	{
		if ($resetuser->reset_passwd(true))
		{
			$PAGE_PROPERTIES['TITLE'] = 'Password Reset Successful';
			include("include/header.php");
			display_header();
						
			println('<center>');
			println('<span class="Success">You have successfully reset your password.</span>');
			println('Please check your e-mail for the new password.');
		}
		else
		{
			require_once("include/globalconfig.php");
			
			$gblconf = new DO_GlobalConfig();
			$gblconf->get((int) get_globalconf_id());
			$admin_email = $gblconf->get_admin_email_address();
			
			$PAGE_PROPERTIES['TITLE'] = 'Password Reset Failed';
			include("include/header.php");
			display_header();
			
			println('<span class="Error">Password reset failed.</span>');
			println('Please contact the administrator (' . $admin_email . ') immediately.');
		}
	}
	else
	{
		$PAGE_PROPERTIES['TITLE'] = 'Password Reset Failed';
		include("include/header.php");
		display_header();
		
		println('<span class="Error">Password reset failed.</span>');
		println('Please <a class="RegularLink" href="' . $_SERVER['PHP_SELF'] . '">try again</a>.');
	}
	println('</center>');
	include("include/footer.php");
}
else
{
	$reset_form =<<<EOD
	<center>
	<form action="{$_SERVER['PHP_SELF']}?action=reset" method="post">
	<span class="FieldName">Enter Username:</span>
	<input name="username" type="text" />
	<input type="submit" value="Reset Password" />
	</form>
	</center>
EOD;
	$PAGE_PROPERTIES['TITLE'] = 'Reset Password';
	include("include/header.php");
	display_header();

	println($reset_form);
	
	include("include/footer.php");
}
?>
Return current item: Echelon - A Writing Center Portal