Hi,
i’m currently trying a new project to create a login page for an assignment i’ve got at work.
I work for a solicitor company in London and need to build a website that will allow clients to login to review their cases.
I’ve got as far as creating a login page, which allows them to login and fails if incorrect, but i’m stuck.
I’m using phpMyAdmin with MYSQL and Dreamweaver MX2004.
I have created a table called users which has the username and password and the login script successfully comminucates with the “users” database.
However, i don’t know how to add users to the database so they can actually login. I don’t think this is hard as i’ve done it before but need someone to refresh my memory.
Lastly,
a problem i’m not sure how to fix.
As each client is different, each court case and files will also be different. Currently, if a client logs in successfully, they are transfered to “success.php” which is a static page. But how do i get specific users to go to their own page. For example, client: JO/PRO/IMM/0985 should login with their username: joproimm0985 password: xxxx and take them to their folder, thus every client can only view their own files and not the whole database.
I hope i have explained in enough detail but any more info can be requested.
Please can someone help me?
Cheers!
[code=php]
mysql_query("INSERT INTO users (username, password, ...any other fields...)
VALUES ('$username', '$password', ...any other fields...)");
[/code]
[code=php]
header("location: success.php?path=$variableName");
[/code]
[code=php]
header("location: $variableName");
[/code]
[CODE]
client1 client2 client3
1,3,7 2,4,6 5,8,9,10
[/CODE]
[CODE]db_cases
1 - case of the missing dog
2 - case of the missing parakeet
3 - case of the missing minx
4 - case of the missing jade diamond
5 - case of the missing burger
6 - case of the missing hot chick
7 - case of the missing chicken
8 - case of the missing french fries
9 - case of the missing ferrari
10 - case of the missing cat
[/CODE]
What exactly are you hoping to have displayed on success.php ?
That should help me give a more relevant answer on how to acchieve what you're wanting.[/QUOTE]
Does each client just have one case reference, or could there be more than one ?
Are the cases held in a database ? If so, what fields / headings are there at the moment (things like date, description, etc) ?
There is no need to display a 'you are being redirected' page, success.php can display information based on the currently logged in user quite simply.[/QUOTE]
[code=php]header("location: ........");[/code]
[code=php]header("location: success.php");[/code]
[code=php]header("location: users/".$_SESSION['username']."/");[/code]
[code=php]<?php require_once('../Connections/connectDB.php'); ?>
<?php
// *** Validate request to login to this site.
session_start();
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($accesscheck)) {
$GLOBALS['PrevUrl'] = $accesscheck;
session_register('PrevUrl');
}
if (isset($_POST['username'])) {
$loginUsername=$_POST['username'];
$password=$_POST['password'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "success.php";
$MM_redirectLoginFailed = "fail.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_connectDB, $connectDB);
$LoginRS__query=sprintf("SELECT username, password FROM users 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, $connectDB) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "";
//declare two session variables and assign them
$GLOBALS['MM_Username'] = $loginUsername;
$GLOBALS['MM_UserGroup'] = $loginStrGroup;
//register the session variables
session_register("MM_Username");
session_register("MM_UserGroup");
if (isset($_SESSION['PrevUrl']) && false) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>[/code]
[code=php]$MM_redirectLoginSuccess = "success.php";[/code]
[code=php]header("Location: " . $MM_redirectLoginSuccess );[/code]
[code=php]$MM_redirectLoginSuccess = "success.php";[/code]
[code=php]$MM_redirectLoginSuccess = "success.php?user=".$loginUsername;[/code]
[code=php]$MM_redirectLoginSuccess = "success.php";[/code]
[code=php]$MM_redirectLoginSuccess = "success.php?user=".$loginUsername;[/code]
,[code=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 = "fail.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;
}
?>[/code]
[code=php]
<?php
session_start();
header("Refresh: 3; URL=".@$_GET['user']."/");
$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 = "fail.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;
}
echo "You will be taken to <b>".@$_GET['user']."/</b> in 3 seconds ...";
?>
[/code]
0.1.9 — BETA 5.5