Forums

PHP

This topic is locked

PHP Logon w/ Dreamweaver

Posted 20 Jan 2006 18:26:24
1
has voted
20 Jan 2006 18:26:24 Marcus Doyle posted:
Ok, I'm having a compatibility issue and I can't seem to figure it out. Here's some code examples, but here's what's going on - this works in Safari, but not in IE Explorer . . .

Logon page generate from Dreamweaver:

<?php require_once('Connections/Hockey.php'); ?>
<?php
// *** Validate request to login to this site.
session_start();

$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($accesscheck)) {
$_SESSION['PrevUrl'] = $accesscheck;
}

if (isset($_POST['textfield1'])) {
$loginUsername=$_POST['textfield1'];
$password=$_POST['textfield2'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "secured/raphome.php";
$MM_redirectLoginFailed = "www.google.com";
$MM_redirecttoReferrer = false;
mysql_select_db($database_Hockey, $Hockey);

$LoginRS__query=sprintf("SELECT username, password FROM authenticate 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, $Hockey) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "";

//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;

if (isset($_SESSION['PrevUrl']) && false) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>

The form that proceeds from that is the standard username & password entry. The logon if incorrect kicks you to Google, but if it succeeds, the redirect brings you right back to the logon page (called log.php).

The page it is supposed to go to is raphome.php. Opening php from there:

<?php require_once('../Connections/Hockey.php'); ?>
<?php
session_start();
$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 = "../log.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;
}
?>

Any ideas?


Marcus

Replies

Replied 02 Feb 2006 18:44:38
02 Feb 2006 18:44:38 Joshua Yip replied:
Hi Marcus,

Could this be caused by IE not able to set cookie?

Joshua

Reply to this topic