<?php



if(!isset($cusername)){
session_start();
require_once("./config.php");
}

if (isset($_POST["username"]) && ($_POST["username"] == $username) && ($_POST["password"] == $password) )
{
   if(isset($_POST['remember'])){
      setcookie("adminname",$username, time()+60*60*24*100, "/");
      setcookie("adminpass", $password, time()+60*60*24*100, "/");
   }

	$_SESSION["admin"] = "true";
   	session_write_close();
	header("Location:./admin.php");
	exit;
}
if (isset($cusername) &&($cusername==$username) && ($cpassword==$password))
{
	$_SESSION["admin"] = "true";
    session_write_close();
	header("Location:./admin.php");
	exit;
}else
 {
	$_SESSION["error"] = "<font color=red>Wrong username or password. Try again.</font>";
	header("Location:./admin.php?wrong=true");
}

?>