Location: PHPKode > scripts > EZ Framework > ez-framework/ex_login.php
<?php
// Config file, needs to be set up properly for authentication to work like below
require_once('../include/config.inc.php');

// Authentication
$auth = new auth();

// If they are logging out
if(isset($_GET['logout']))
{
	// This will logout the user sessions and/or cookies and update the session end time in the database
	$auth->logout();
}

// Already logged in, send to their page
if( $auth->check() )
{
	header("Location: myaccount.php");
}

// Form Handling
$f = new form_handle();

if(isset($_POST['logmein']))
{
	// allowed request method
	$f->allowMethod('POST');
	// validation rules
	$f->validate
	(array
		(
			array('req','password','password','Required'),
			array('req','login','login','Required'),
		)
	);
	// Clean posted variables
	$f->stripAll();
	// if validation passed
	if( $f->pass( ) )
	{
		// if login passed
		if( $auth->login( $f->method['login'], md5( $f->method['password'] ) ) )
		{
			header("Location: myaccount.php");
		// Didn't pass login
		} else
			$f->forceFail('notfound','User Name / Password Not Found');
	}
}

?>
<html>
<head>
<title>
</title>
</head>
<body>

<?php $_REQUEST_FILE[] = __FILE__; ?>
<div id="formcontainer"> 

	<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">
	
		<div class="row">
			<div class="col1">
				Login
			</div>
			<div class="col2">
				<input type="text" size="20" maxlength="20" <?php echo $f->setText('login'); ?> />
			</div>
			<div class="col3">
				<?php echo $f->getError('login'); ?>
			</div>
		</div>
		
		<div class="row">
			<div class="col1">
				Password
			</div>
			<div class="col2">
				<input type="password" size="20"  maxlength="20" <?php echo $f->setText('password'); ?> />
			</div>
			<div class="col3">
				<?php echo $f->getError('password'); ?>
			</div>
		</div>
		
		
		<div class="row"> 
			<input type="hidden" name="logmein" value="logmein" />
			<input alt="Submit Me" title="Submt Me!" type="submit" name="Create_User" value="Submit" />
		<?php echo $f->getError('notfound'); ?>
		</div>
	</form>
</div>

</body>
</html>
Return current item: EZ Framework