not really all that hard really. Makes things really easy to maintain. the code below is for a small admin area for a site i maintain (feel free to join though if you’re a music artist or need an app)
[php]
<?php
session_start();
require_once 'config.php';
require_once 'functions.php';
switch($_GET['do']) {
case 'logout':
include 'logout.php';
break;
}
if($_COOKIE['adminuser']) {
$result = mysql_query("SELECT * FROM venzo_xxxx WHERE username = '".($_COOKIE['adminuser'])."' LIMIT 1") or die(mysql_error());
if(mysql_num_rows($result) == 1) {
$row = mysql_fetch_assoc($result);
$_SESSION['adminname'] = $row['name'];
}
}
if(isset($_POST['clientlogin'])) {
$result = mysql_query("SELECT * FROM venzo_xxxx WHERE username = '".escape($_POST['clientname'])."' AND password = '".md5($_POST['clientpass'])."' LIMIT 1") or die(mysql_error());
if(mysql_num_rows($result) == 1) {
$row = mysql_fetch_assoc($result);
$_SESSION['adminname'] = $row['name'];
setcookie('adminuser', $row['username'], time()+60*60*24*30, '/', '.venzodigital.com');
setcookie('adminpass', $row['password'], time()+60*60*24*30, '/', '.venzodigital.com');
setcookie('adminid', $row['id'], time()+60*60*24*30, '/', '.venzodigital.com');
//echo mysql_num_rows($result);
header("Location: index.php");
} else {
$error = 'Login Attempt Failed';
}
}
?>
VMG Administration
<?php
if($_COOKIE['adminuser']) {
?>
Copyright <?=date("Y") ?> Venzo Digital. All Rights Reserved.
[/php]
Every page is loaded into the content area via php and a url link. the switch and cases capture the pages that need to be loaded. forums you'd load up in seperate window or tab though. the mysql table names i had to x out for security reasons.