Location: PHPKode > projects > Crown of Evanion > final/login.php
<?php
/*
*   This file is part of 'Crown of Evanion'.
*
*    'Crown of Evanion' is free software; you can redistribute it and/or modify
*    it under the terms of the GNU General Public License as published by
*    the Free Software Foundation; either version 2 of the License, or
*    (at your option) any later version.
*
*    'Crown of Evanion' is distributed in the hope that it will be useful,
*    but WITHOUT ANY WARRANTY; without even the implied warranty of
*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*    GNU General Public License for more details.
*
*    You should have received a copy of the GNU General Public License
*    along with 'Crown of Evanion'; if not, write to the Free Software
*    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/
$title = "Login";
include("include.php");

if(! $page) { #Default page.
	$error = $_REQUEST['error'];
	
	$err = array( 
	'1' => "<h5>Invalid Username/Password Combinations. Try again.</h5>",
	'2' => "<h5>Your account has been disabled. If you see this as an error, e-mail the <a href=mailto:hide@address.com>webmaster.</a></h5>",
	);
	
	echo "You may log into your CyberPets account below. Remember, passwords are case sensative.
	<br>$err[$error]<br>
	<form action=\"$PHP_SELF\" method=\"POST\">
	<input type=\"hidden\" name=\"page\" value=\"proc\">
	<div class=\"section\">
	<table>
	<tr>
	<th scope=\"row\">Username</th>
	<td><input type=\"text\" name=\"user\" maxlength=\"12\"></td>
	</tr>
	<tr>
	<th scope=\"row\">Password</th>
	<td><input type=\"password\" name=\"pass\" id=\"pass\"></td>
	</tr>
	<td>
	<input type=\"submit\" value=\"Login\">
	</td>
	</table>
	<p class=\"black\"><strong>Don't have an account? <a href=\"register.php\">Register one.</a></strong></p>
	
	</div>
	";
}

if($page == "proc") {
	$user = $_POST['user'];
	$pass = $_POST['pass'];
	$authpw = md5($pass);
	
	$select = mysql_query("SELECT username,password,ban FROM users WHERE username = '$user'");
	$num = mysql_num_rows($select);
	$data = mysql_fetch_array($select);
	
	if($num == 0) {
		header("location: login.php?error=1");
	}
	else if($data[password] != $authpw) {
		header("location: login.php?error=1");
	}
	else if($data[ban] == 2) {
		header("location: login.php?error=2");
	}
	else if($data[password] == $authpw) {
		setcookie ("CPH_Usr", $data[username], time()+7776000);
		setcookie ("CPH_Psw", $authpw, time()+7776000);
		header("location: index.php");
	}
}


if($page == "logout") {
	setcookie ("CPH_Usr", $user, time()-7776000);
	setcookie ("CPH_Psw", $authpw, time()-7776000);
	header("location: index.php");
}

include("footer.php");
?>
Return current item: Crown of Evanion