/    Sign up×
Community /Pin to ProfileBookmark

php unique login not working

I am using the following code to direct logged in users to a unique members area but when I log in my browser returns a 404 not found.
<?php virtual(‘/Connections/members.php’); ?>
<?php
if (!function_exists(“GetSQLValueString”)) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = “”, $theNotDefinedValue = “”)
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

$theValue = function_exists(“mysql_real_escape_string”) ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case “text”:
$theValue = ($theValue != “”) ? “‘” . $theValue . “‘” : “NULL”;
break;

case “long”:
case “int”:
$theValue = ($theValue != “”) ? intval($theValue) : “NULL”;
break;
case “double”:
$theValue = ($theValue != “”) ? “‘” . doubleval($theValue) . “‘” : “NULL”;
break;
case “date”:
$theValue = ($theValue != “”) ? “‘” . $theValue . “‘” : “NULL”;
break;
case “defined”:
$theValue = ($theValue != “”) ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();
}

$loginFormAction = $_SERVER[‘PHP_SELF’];
if (isset($_
GET[‘accesscheck’])) {
$_SESSION[‘PrevUrl’] = $_GET[‘accesscheck’];
}

if (isset($_POST[‘username’])) {
$loginUsername=$_
POST[‘username’];
$password=$_POST[‘passwod’];
$MM_fldUserAuthorization = “”;
$MM_redirectLoginSuccess = “$loginUsername.php”;
$MM_redirectLoginFailed = “/index.htm”;
$MM_redirecttoReferrer = false;
mysql_select_db($database_members, $members);

$LoginRS__query=sprintf(“SELECT username, password FROM `access` WHERE username=%s AND password=%s”,
GetSQLValueString($loginUsername, “text”), GetSQLValueString($password, “text”));

$LoginRS = mysql_query($LoginRS__query, $members) 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 );
}
}
?>

user name is newmont
members area is newmont.php and located in the root directory
any help would be appreciated.

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@NightShift58Mar 17.2007 — I am using the following code to direct logged in users to a unique members area but when I log in my browser returns a 404 not found. [code=php]<?php virtual('/Connections/members.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;

case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();
}

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

if (isset($_POST['username'])) {
$loginUsername=$_POST['username'];
$password=$_POST['passwod'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "$loginUsername.php";
$MM_redirectLoginFailed = "/index.htm";
$MM_redirecttoReferrer = false;
mysql_select_db($database_members, $members);

$LoginRS__query=sprintf("SELECT username, password FROM access WHERE username=%s AND password=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));

$LoginRS = mysql_query($LoginRS__query, $members) 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 );
}
}
?>[/code]


user name is newmont

members area is newmont.php and located in the root directory

any help would be appreciated.
Copy linkTweet thisAlerts:
@bokehMar 17.2007 — This code has got nothing to do with logging users into a system.
×

Success!

Help @twoaspen spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...