I need a simple login script that has the ability to redirect a user.

For example:
- I want to be able to protect certain pages so that a user has to login to access them (in this case they wouldn't get redirected)
- Then in another case I would want the ability to redirect a user based on their login. For example, have a login box and store it as a session or cookie, then they could click on a My Account link and be directed to their specific folder.

For registration, I would need a username, password, company name, email address, and possibly a homedirectory variable (used to determine where to redirect them to).

Does something out there exist?

as an example from Dreamweaver login script:

//connect to your db through another file and include it:

if (!isset($_SESSION)) {

$loginFormAction = $_SERVER;
if (isset($_GET)) {

if (isset($_POST)) {
$MM_fldUserAuthorization = "";
//if they match the criteria, redirect to the allowed page
$MM_redirectLoginSuccess = "page_allowed_to access.php";
//if they have not passed the authorization, redirect bact to login page
$MM_redirectLoginFailed = "login.php";
$MM_redirecttoReferrer = false;
mysql_select_db($your_database, $your_db_table);

$LoginRS__query=sprintf("SELECT username, password FROM your_access_table WHERE username='%s' AND password='%s'",
get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password));

$LoginRS = mysql_query($LoginRS__query, $your_db_table) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "";

//declare two session variables and assign them
$_SESSION = $loginUsername;
$_SESSION = $loginStrGroup;

if (isset($_SESSION) && false) {
$MM_redirectLoginSuccess = $_SESSION;
header("Location: " . $MM_redirectLoginSuccess );
else {
header("Location: ". $MM_redirectLoginFailed );

Now in the body of your page include a form :

<form id="form1" name="form1" method="POST" action="<?php echo $loginFormAction; ?>">
<table width="400" border="0">
<td colspan="2"><div align="center" class="style1"> Login <br />
Please use your Network Password </div></td>
<td><span class="style2">Username:</span></td>
<td><input name="username" type="text" id="username" size="25" /></td>
<td><span class="style2">Password:</span></td>
<td><input name="password" type="password" id="password" size="25" /></td>
<td colspan="2"><div align="center">
<input name="Login" type="submit" id="Login" value="Submit" />

once the user has passed the verification send the user to the page desired and only allow access based on the credentials supplied like this (Place this at the top of the page restricting access):

if (!isset($_SESSION)) {
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
// For security, start by assuming the visitor is NOT authorized.
$isValid = False;

// When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
// Therefore, we know that a user is NOT logged in if that Session variable is blank.
if (!empty($UserName)) {
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
// Parse the strings into arrays.
$arrUsers = Explode(",", $strUsers);
$arrGroups = Explode(",", $strGroups);
if (in_array($UserName, $arrUsers)) {
$isValid = true;
// Or, you may restrict access to only certain users based on their username.
if (in_array($UserGroup, $arrGroups)) {
$isValid = true;
if (($strUsers == "") && true) {
$isValid = true;
return $isValid;

$MM_restrictGoTo = "login.php";
if (!((isset($_SESSION)) && (isAuthorized("",$MM_authorizedUsers, $_SESSION, $_SESSION)))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER;
if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)
$MM_referrer .= "?" . $QUERY_STRING;
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo);

hope this helps!