Location: PHPKode > projects > ArticleSetup > ArticleSetup-v1-1/upload/login.php
<?php $cathead = 0;
include('config.php');
session_start();

if (isset($_POST['userid']) && isset($_POST['password'])) {
	// if the user has just tried to log in 
	$username = $_POST['userid']; 
	$password = $_POST['password'];
	
	$query = 'select * from authors ' 
			 ."where username ='$username' "
			 ." and password = md5('$password')";
				 
	$result = mysql_query($query,$connection) or die(mysql_error());

		
	if (mysql_num_rows($result)) {
		// if they are in the database register the user id 
		$_SESSION['valid_user'] = $username;
	} else {
		header ("Location: login.php?login=failed");
	}
	 
} 

if (isset($_SESSION['valid_user'])) {
	 if ($_POST['remember']) { // Set cookie if user checked remember me
	 	setcookie("cookname", $username, time()+60*60*24*100, "/");
    	setcookie("cookpass", md5($password), time()+60*60*24*100, "/");
    }
	header ("Location: author/index.php"); 
} 
	
	include('header.php'); 
	include('sidebar.php'); 
	
	// Setup the login template
	$logintemp = new Template("templates/".$template."/login.tpl");
	$logintemp->set("siteurl", $siteurl);
	
	if ($_GET["login"] == "failed") { // if they've tried and failed to log in 
		$logintemp->set("loginerror", '<div class="alert" style="width:255px;">
		Incorrect Username or password</div>');
	} else {
		$logintemp->set("loginerror", '');
	}
	
	$logintemp->set("captcha", 'require_once(\'recaptchalib.php\');
	$publickey = "your_public_key"; // you got this from the signup page
  	echo recaptcha_get_html($publickey);');
	
	if($_GET["account"] == "new") {
		$logintemp->set("regalert", '
		<div class="alert" style="text-align: center; width:100%;">
		Your Account has been Created. You may login to the left.</div>');
	} else {
		$logintemp->set("regalert", '');
		if($_GET["error"] == "email") {
			$logintemp->set("regalert",  '<div class="alert" style="text-align: center; 
							width:280px;">That email address is already in use!</div>');
		}
		if($_GET["error"] == "captcha") {
			$logintemp->set("regalert",  '<div class="alert" style="text-align: center; 
							width:280px;">ERROR: incorrect verification code</div>');
		}
		if($_GET["error"] == "user") {
			$logintemp->set("regalert", '<div class="alert"  style="text-align: center; 
						width:280px;">That username address is already in use!</div>');
		}
	}
	
// Outputs the template!
	 
	echo $logintemp->output();

	include('obinclude.php'); 
?>
Return current item: ArticleSetup