Salut,
J'ai un soucis pour identifier et rediriger un utilisateur sur mon site.
Normalement quand on rentre l'adresse mail et le mot de passe en cliquant sur connecté on arrive à une page restreinte en fonction du mot de passe et du mail.
Mon utilisateur est bien enregistre dans la bdd mysql, je travaille avec easy php ... mais rien ne se passe. Le soucis c'est que je ne peux pas vraiment tester les autres pages en direct sans à chaque fois modifier le code d'accés car le code pour restreindre l'acces marche tres bien et notifie que je ne me suis pas identifier si j'essaie de rentrer l'url à la main.
Voici le code de mon menu où se trouve le formulaire d'identification:
->vraiment besoin d'aide merci!!
<?php require_once('Connections/electricite.php'); ?><?php
//initialize the session
if (!isset($_SESSION)) {
session_start();
}
// ** Logout the current user. **
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "" )){
$logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true" )){
//to fully log out a visitor we need to clear the session varialbles
$_SESSION['MM_Username'] = NULL;
$_SESSION['MM_UserGroup'] = NULL;
$_SESSION['PrevUrl'] = NULL;
unset($_SESSION['MM_Username']);
unset($_SESSION['MM_UserGroup']);
unset($_SESSION['PrevUrl']);
$logoutGoTo = "dothalelectricite_accueil.php";
if ($logoutGoTo) {
header("Location: $logoutGoTo" );
exit;
}
}
?>
<?php
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "achat" )) {
$insertSQL = sprintf("INSERT INTO dothal_panier (client, article, quantite) VALUES (%s, %s, %s)",
GetSQLValueString($_POST['client'], "text" ),
GetSQLValueString($_POST['article'], "int" ),
GetSQLValueString($_POST['quantité'], "int" ));
mysql_select_db($database_electricite, $electricite);
$Result1 = mysql_query($insertSQL, $electricite) or die(mysql_error());
$insertGoTo = "account/dothalelectricite_panier.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
$paramclient_panier = "0";
if (isset($_SESSION [ 'MM_Username' ])) {
$paramclient_panier = (get_magic_quotes_gpc()) ? $_SESSION [ 'MM_Username' ] : addslashes($_SESSION [ 'MM_Username' ]);
}
$paramarticle_panier = "0";
if (isset($_GET [ 'id' ])) {
$paramarticle_panier = (get_magic_quotes_gpc()) ? $_GET [ 'id' ] : addslashes($_GET [ 'id' ]);
}
mysql_select_db($database_electricite, $electricite);
$query_panier = sprintf("SELECT id FROM dothal_panier WHERE client = '%s' AND article = '%s'", $paramclient_panier,$paramarticle_panier);
$panier = mysql_query($query_panier, $electricite) or die(mysql_error());
$row_panier = mysql_fetch_assoc($panier);
$totalRows_panier = mysql_num_rows($panier);
?>
<?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['Adresse mail'])) {
$loginUsername=$_POST['Adresse mail'];
$password=$_POST['mot de passe'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "dothalelectricite_accueilclient.php";
$MM_redirectLoginFailed = "dothalelectricite_ko.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_electricite, $electricite);
$LoginRS__query=sprintf("SELECT mail, mot_de_passe FROM dothal_client WHERE mail='%s' AND mot_de_passe='%s'",
get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password));
$LoginRS = mysql_query($LoginRS__query, $electricite) 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 );
}
}
?>
<!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=iso-8859-1" />
<title>Document sans titre</title>
</head>
<body>
<div class="deco_menu">
<table align="center" width="200" border="0" >
<tr>
<td>
<font color="#CCCCCC">
<?php
$date=date("d-m-y" );
echo "DATE DU JOUR: $date";
?> </font>
<?php if(!isset ($_SESSION['MM_Username'])) {?>
<font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"> <li>S'IDENTIFIER</li> </font>
<form id="se_connecter" name="se_connecter" method="POST" action="<?php echo $loginFormAction; ?>" >
<font color="#FFFFFF" size="1" face="Arial, Helvetica, sans-serif"> Adresse mail </font> <br />
<input name="Adresse mail" type="text" id="Adresse mail" size="15" maxlength="64"/><br />
<font color="#FFFFFF" size="1" face="Arial, Helvetica, sans-serif"> Mot de passe</font> <br />
<input name="mot de passe" type="text" id="mot de passe" size="15" maxlength="6" /><BR /><br />
<label>
<input type="submit" name="Submit" value="se connecter" />
</label>
</form>
<?php } ?>
<?php if (isset ($_SESSION['MM_Username'])) { ?>
</td>
</tr>
<tr>
<td>
<font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><li><a href=<?php echo $logoutAction ?>>SE DECONNECTER </A> </li>
</font>
<?php if ($totalRows_panier == 0) { // Show if recordset empty ?>
<form action="<?php echo $editFormAction; ?>" method="POST" name="achat">
<input name="client" type="hidden" value="<?php echo $_SESSION['MM_Username '];?>" />
<input name="article" type="hidden" value="<?php echo $row_Produit['id '] ; ?>" />
<input name="quantité" type="hidden" value="1" />
<input name="acheter" type="submit" value="acheter" />
<input type="hidden" name="MM_insert" value="achat">
</form>
<?php if ($totalRows_panier > 0) { // Show if recordset not empty ?>
<?php } // Show if recordset empty ?>
<font face="Arial, Helvetica, sans-serif" color="#FF0000" size="4"><a href="account/dothalelectricite_panier.php">"Cet article est déjà présent dans votre panier, cliquez ici pour en modifier la quantité commandée."</a></font>
<?php } // Show if recordset not empty ?>
<?php } ?> </td>
</tr>
<tr>
<td>
<font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><li><A href="dothalelectricite_signin.php">CREER UN COMPTE </A> </li> </font>
</td>
</tr>
</table>
</div>
</body>
</html>
<?php
mysql_free_result($panier);
?>