Location: PHPKode > scripts > Impleo Music Collection Script > impleo/admin/index.php
<?php
/* ----------------------------------------------------------------------------
 * "THE BEER-WARE LICENSE" (Revision 42):
 * <hide@address.com> wrote this file. As long as you retain this notice you
 * can do whatever you want with this stuff. If we meet some day, and you think
 * this stuff is worth it, you can buy me a beer in return Christoffer Kjeldgaard Petersen
 * ----------------------------------------------------------------------------
 */

session_start();

require_once(dirname(__FILE__) . '/../classes/ImpleoTemplate.class.php');
require_once(dirname(__FILE__) . '/../classes/Factory.class.php');

$tpl = new ImpleoTemplate("adminlogin.tpl");
$factory = Factory::getInstance();

// Login:
$hasError = false;
if ($_POST['login'])
{
    $username = $_POST['username'];
    $password = $_POST['password'];

    if ($factory->loginUser($username, $password))
    {
        $_SESSION['login'] = 1;
        $_SESSION['username'] = $username;
    	header("Location: add-record.php");
        exit;
    }
    else
    {
        $hasError = true;
        $errorMsg = "You have specified an incorrect username, or an invalid password.";
        $tpl->assign('errorMsg', $errorMsg);
    }
}

// Logout:
if (isset($_GET['logout']))
{
   unset($_SESSION['login']);
   unset($_SESSION['username']);
   header("Location: ./");
}

$tpl->assign('hasError', $hasError);

header("content-type:text/html;charset=utf-8");
$tpl->displayTemplate();

?>
Return current item: Impleo Music Collection Script