mon scripte php peu gerer une seule session, je veut le modifier pour gerer 2 session (admin et surveillant).
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();
}
require_once('Connections/connexion.php');
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}
if (isset($_POST['login'])) {
$loginUsername=$_POST['login'];
$password=$_POST['password'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "index.php";
$MM_redirectLoginFailed = "login.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_connexion, $connexion);
$LoginRS__query=sprintf("SELECT login, password FROM utilisateur WHERE login='".$loginUsername."' AND password='".$password."'");
$LoginRS = mysql_query($LoginRS__query, $connexion) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "";
if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;
if (isset($_SESSION['PrevUrl']) && false) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
?>
<script language="javascript">
window.location='index.php';
</script>
<?php
}
else {
?>
<script language="javascript">
window.location='login.php?err=1';
</script>
<?php
}
}
?>
<?php require_once('Connections/connexion.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$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;
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>lOGIN</title>
<style type="text/css">
body {
background-image: url(image11/wallpaper2.jpg);
}
</style>
</head>
<body>
<form action="<?php echo $loginFormAction; ?>" method="POST" name="form1" id="form1">
<p> </p>
<p> </p>
<p> </p>
<table align="center" border="0">
<tr valign="baseline">
<td nowrap="nowrap" align="center">Login:</td>
<td align="center"><input type="text" name="login" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="center">Password:</td>
<td align="center"><input type="password" name="password" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td colspan="2" align="center" nowrap="nowrap"><input type="submit" value="login" /></td>
</tr>
<tr valign="baseline">
<td colspan="2" align="center" nowrap="nowrap">
</td>
</tr>
</table>
</form>
</body>
</html>