<?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['nom'])) {
$loginUsername=$_POST['nom'];
$password=$_POST['password'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "test.php";
$MM_redirectLoginFailed = "ko.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_Nhac, $Nhac);
$LoginRS__query=sprintf("SELECT nom, password FROM iden WHERE nom='%s' AND password='%s'",
get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password));
$LoginRS = mysql_query($LoginRS__query, $Nhac) 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 );
}
}
?>
<form ACTION="<?php echo $loginFormAction; ?>" method="POST" name="indentifier" id="indentifier">
<? if(empty($_SESSION["MM_Username"])) { ?>
<p>Identifiez vous </p>
<table width="380" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="116" height="33">Nom</td>
<td width="264"><input name="nom" type="text" id="nom"></td>
</tr>
<tr>
<td>Mot de passe</td>
<td><input name="password" type="password" id="password"></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input type="submit" name="Submit" value="Envoyer">
</div></td>
</tr>
</table>
<? } else { ?>
<p>Bonjour <?= $_SESSION["MM_Username"]; ?></p>
<? } ?>
</form>
Partager