Skip to main content
Participant
August 3, 2008
Question

Unable to loginto protected page

  • August 3, 2008
  • 4 replies
  • 318 views
Hello:

I am using PHP, MYSQL hosted platform. I have created and manually inputted data to a login database. I have created a login page and also created a protected page to log into. It gives me an error despite inputting correct login information. If I loginto a non protected page, it works.

I have listed the code below. Thank you for your time and effort. Much appreciated.

CODE---------------------

<?php
session_start();
$MM_authorizedUsers = "4";
$MM_donotCheckaccess = "false";

// *** 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 == "") && false) {
$isValid = true;
}
}
return $isValid;
}

$MM_restrictGoTo = "require.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
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);
exit;
}
?>
This topic is closed to new replies. Start a new post to keep the conversation going.

4 replies

Inspiring
August 3, 2008
MX04WIZ wrote:
> It gives me an error despite inputting correct
> login information.

Unless you say what the error is, anything is pure guesswork.

--
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
MX04WIZAuthor
Participant
August 4, 2008
The error message I get is the exact same error as I would get if I typed in wrong log-in information. Thank you.