Location: PHPKode > projects > OpenBlog mini > OpenBlog mini 1.0/admin.php
<?php
	session_start();

	include 'config.php';
	
	echo $html_header;
	
	// This page is self-referencing and allows a user to log-in and log-out (and be redirected)
	if ($_POST['logout'] != 'YES') {

		if (($_POST['username'] == $admin_username) && ($_POST['password'] == $admin_password)) { 
			$_SESSION['logged_in'] = 'YES'; 
			echo "Success: You have logged-in.";
			header( 'Location: index.php' ) ;
		}
		else { 
			if ((!empty($_POST['username'])) || (!empty($_POST['password']))) {	echo "Error: You have entered the wrong username/password.<br><br>"; }
		}

		if ($_SESSION['logged_in'] != 'YES') {
			echo "\n\n<b>Administrator Log-In:</b><br><br><form method='post' action='admin.php' style='display: inline; margin: 0;'>\n Username: <input type='text' size='15' name='username'>\n &nbsp; Password: <input type='password' size='15' name='password'>\n &nbsp; <input type='submit' value='Log-In'>\n</form>\n";
		}
		else {
			$_SESSION['logout'] = "\n\n<br><hr><br>\n<form method='post' action='view.php' style='display: inline; margin: 0;'>\n<input type='submit' value='Create New Blog Post'>\n</form><br><br><form method='post' action='admin.php' style='display: inline; margin: 0;'>\n <input type='hidden' size='15' name='logout' value='YES'>\n<input type='submit' value='Log-Out'>\n</form><br><br>&nbsp;\n";
			header( 'Location: index.php' ) ;
		}
	}
	else {	
		session_destroy();
		echo "Success: You have logged-out.";
		header( 'Location: index.php' ) ;
	}
	
	echo $html_footer;
	
?>
Return current item: OpenBlog mini