Ask a Question related to Macromedia Dynamic HTML, Design and Development.
-
redman181 #1
Problems with login script-PHP/Mysql
I use Dreamweaver 8 to do my coding and for some reason my login doesn't work
at all.
If I use the "Restrict Access to page" script supplied by Dreanweaver 8, I go
straight to the fail page.
Here is the login script:
<?php require_once('Connections/bsg_med.php'); ?><?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();
}
$loginFormAction = $_SERVER;
if (isset($_GET)) {
$_SESSION = $_GET;
}
if (isset($_POST)) {
$loginUsername=$_POST;
$password=$_POST;
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "med_sida.php";
$MM_redirectLoginFailed = "links.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_bsg_med, $bsg_med);
$LoginRS__query=sprintf("SELECT Medlemskod, Pass FROM medlemstabell1 WHERE
Medlemskod='%s' AND Pass='%s'",
get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername),
get_magic_quotes_gpc() ? $password : addslashes($password));
$LoginRS = mysql_query($LoginRS__query, $bsg_med) 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 );
}
}
?>
and here is the Restrict to Access script:
<?php
if (!isset($_SESSION)) {
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 = "links.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);
exit;
}
?>
If someone could please help me sort this mess out, and tell me if this is
secure enough it'll be appreciated.
Thanks
redman181 Guest
-
Need Login Script Help
I need this exact setup. can someone please please please provide me with code for something just like this and tell me how you add it to my page... -
Simple login script?
Hello, I wonder if anyone can help me with a very simple login procedure? I have a database (DSN name is mydsn) with fields "username1" and... -
ASP Login Script not working
Applies to: Microsoft FrontPage 2000, Microsoft Access 2000, IIS 5.0 Operating System: Microsoft Windows 2000 Professional I am trying to protect... -
ASP login script works sometimes !?
Hi folks ! I finally got my login-page to run, but the thing is that it seems to live a life of its own. sometimes i can log in and sometimes not.... -
Login Script
Hi there all, im new to this newsgroup, and also new to php. Anyway, im after a php login script, but i want it so it can have lots of different...



Reply With Quote

