bonjour a tous!
je suis debutant(dreamweaver CS3) en php et j'ai un problème.
1. j'ai une page de connexion login.php
2. Une autre page vers laquelle l'utilisateur est dirigé quand il reussi a se connecter afficher.php
Mon soucis est que je souhaiterais afficher les données attriqués uniquement a cet utilisateur bien precis.
Dans ma requête vous verez le nom utilisateur que mis definit pour voir si ses ok. Et sa marche. Mais je sais pas comment rendre dynamique c'est à dire créer une variable qui récupère le nom login de la personne qui se connecte.
Code PHP :
$query_rs = "SELECT documents.nom, documents.lien_serveur, documents.date_doc FROM documents WHERE id_role IN (SELECT id_role FROM login_role WHERE id_users=(SELECT id_users FROM login where login='[u]mscuser1[/u]'))";
login.php
<?php require_once('Connections/connect.php'); ?>
<?php
// Load the common classes
require_once('includes/common/KT_common.php');
// Load the tNG classes
require_once('includes/tng/tNG.inc.php');
// Make a transaction dispatcher instance
$tNGs = new tNG_dispatcher("");
// Make unified connection variable
$conn_connect = new KT_connection($connect, $database_connect);
// Start trigger
$formValidation = new tNG_FormValidation();
$formValidation->addField("kt_login_user", true, "text", "", "", "", "");
$formValidation->addField("kt_login_password", true, "text", "", "", "", "");
$tNGs->prepareValidation($formValidation);
// End trigger
// Make a login transaction instance
$loginTransaction = new tNG_login($conn_connect);
$tNGs->addTransaction($loginTransaction);
// Register triggers
$loginTransaction->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "POST", "kt_login1");
$loginTransaction->registerTrigger("BEFORE", "Trigger_Default_FormValidation", 10, $formValidation);
$loginTransaction->registerTrigger("END", "Trigger_Default_Redirect", 99, "{kt_login_redirect}");
// Add columns
$loginTransaction->addColumn("kt_login_user", "STRING_TYPE", "POST", "kt_login_user");
$loginTransaction->addColumn("kt_login_password", "STRING_TYPE", "POST", "kt_login_password");
$loginTransaction->addColumn("kt_login_rememberme", "CHECKBOX_1_0_TYPE", "POST", "kt_login_rememberme", "0");
// End of login transaction instance
// Execute all the registered transactions
$tNGs->executeTransactions();
// Get the transaction recordset
$rscustom = $tNGs->getRecordset("custom");
$row_rscustom = mysql_fetch_assoc($rscustom);
$totalRows_rscustom = mysql_num_rows($rscustom);
?><!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>Document sans titre</title>
<link href="includes/skins/mxkollection3.css" rel="stylesheet" type="text/css" media="all" />
<script src="includes/common/js/base.js" type="text/javascript"></script>
<script src="includes/common/js/utility.js" type="text/javascript"></script>
<script src="includes/skins/style.js" type="text/javascript"></script>
<?php echo $tNGs->displayValidationRules();?>
</head>
<body>
<table width="385" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="19" colspan="2" align="center" valign="middle">
<?php
echo $tNGs->getLoginMsg();
?>
<?php
echo $tNGs->getErrorMsg();
?>
<form method="post" id="form1" class="KT_tngformerror" action="<?php echo KT_escapeAttribute(KT_getFullUri()); ?>">
<table cellpadding="2" cellspacing="0" class="KT_tngtable">
<tr>
<td class="KT_th"><label for="kt_login_user">Username:</label></td>
<td><input type="text" name="kt_login_user" id="kt_login_user" value="<?php echo KT_escapeAttribute($row_rscustom['kt_login_user']); ?>" size="32" />
<?php echo $tNGs->displayFieldHint("kt_login_user");?> <?php echo $tNGs->displayFieldError("custom", "kt_login_user"); ?> </td>
</tr>
<tr>
<td class="KT_th"><label for="kt_login_password">Password:</label></td>
<td><input type="password" name="kt_login_password" id="kt_login_password" value="" size="32" />
<?php echo $tNGs->displayFieldHint("kt_login_password");?> <?php echo $tNGs->displayFieldError("custom", "kt_login_password"); ?> </td>
</tr>
<tr>
<td class="KT_th"><label for="kt_login_rememberme">Remember me:</label></td>
<td><input <?php if (!(strcmp(KT_escapeAttribute($row_rscustom['kt_login_rememberme']),"1"))) {echo "checked";} ?> type="checkbox" name="kt_login_rememberme" id="kt_login_rememberme" value="1" />
<?php echo $tNGs->displayFieldError("custom", "kt_login_rememberme"); ?> </td>
</tr>
<tr class="KT_buttons">
<td colspan="2"><input type="submit" name="kt_login1" id="kt_login1" value="Login" />
</td>
</tr>
</table>
<a href="forgot_password.php">Forgot your password?</a>
</form>
<p> </p></td>
</tr>
</table>
</body>
</html>
affiche.php
Code PHP :
<?php require_once('Connections/connect.php'); ?>
<?php
// Load the tNG classes
require_once('includes/tng/tNG.inc.php');
// Make unified connection variable
$conn_connect = new KT_connection($connect, $database_connect);
//Start Restrict Access To Page
$restrict = new tNG_RestrictAccess($conn_connect, "");
//Grand Levels: Level
$restrict->addLevel("1");
$restrict->addLevel("2");
$restrict->Execute();
//End Restrict Access To Page
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$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;
}
}
$maxRows_rs = 10;
$pageNum_rs = 0;
if (isset($_GET['pageNum_rs'])) {
$pageNum_rs = $_GET['pageNum_rs'];
}
$startRow_rs = $pageNum_rs * $maxRows_rs;
mysql_select_db($database_connect, $connect);
$query_rs = "SELECT documents.nom, documents.lien_serveur, documents.date_doc FROM documents WHERE id_role IN (SELECT id_role FROM login_role WHERE id_users=(SELECT id_users FROM login where login='mscuser1'))";
$query_limit_rs = sprintf("%s LIMIT %d, %d", $query_rs, $startRow_rs, $maxRows_rs);
$rs = mysql_query($query_limit_rs, $connect) or die(mysql_error());
$row_rs = mysql_fetch_assoc($rs);
if (isset($_GET['totalRows_rs'])) {
$totalRows_rs = $_GET['totalRows_rs'];
} else {
$all_rs = mysql_query($query_rs);
$totalRows_rs = mysql_num_rows($all_rs);
}
$totalPages_rs = ceil($totalRows_rs/$maxRows_rs)-1;
// Initialize the Alternate Color counter
$ac_sw1 = 0;
// Download File downloadObj1
$downloadObj1 = new tNG_Download("", "KT_download1");
// Execute
$downloadObj1->setFolder("uploads/");
$downloadObj1->setRenameRule("{rs.lien_serveur}");
$downloadObj1->Execute();
// Download File downloadObj1
$downloadObj1 = new tNG_Download("", "KT_download1");
// Execute
$downloadObj1->setFolder("uploads/");
$downloadObj1->setRenameRule("{rs.lien_serveur}");
$downloadObj1->Execute();
?><!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>Document sans titre</title>
<style type="text/css">
<!--
.Style10 {font-size: 12px; font-family: sans-serif;}
.Style11 {
font-size: 12px;
font-family: sans-serif;
font-weight: bold;
color: #FF0000;
}
.Style13 {font-size: 12px; font-family: sans-serif; font-weight: bold; }
.Style14 {color: #FFFFFF}
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: none;
}
a:active {
text-decoration: none;
}
.Style15 {color: #990000}
-->
</style>
</head>
<body>
<table width="971" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="192"> </td>
<td width="779" class="Style11"><?php echo $_SESSION['kt_login_user']; ?></td>
</tr>
<tr>
<td height="242" colspan="2" align="center" valign="middle"><table width="779" border="0" cellspacing="1" cellpadding="1">
<tr>
<td width="769" colspan="5"><p> </p>
<table width="765" border="1" align="center" cellpadding="1" cellspacing="2">
<tr>
<th width="187" bgcolor="#333333" scope="row"><div align="center" class="Style14"><span class="Style13">Nom document</span></div></th>
<td width="367" bgcolor="#333333"><div align="center" class="Style14"><span class="Style13">Télécharger</span></div></td>
<td width="189" bgcolor="#333333"><div align="center" class="Style14"><span class="Style13">Date document</span></div></td>
</tr>
<?php do { ?>
<tr bgcolor="<?php echo ($ac_sw1++%2==0)?"#ECE9D8":"#FFFFFF"; ?>" onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor=''">
<th scope="row"><div align="left" class="Style10"><?php echo $row_rs['nom']; ?></div></th>
<td><div align="left" class="Style11"><a href="<?php echo $downloadObj1->getDownloadLink(); ?>" class="Style15 Style15"><?php echo $row_rs['lien_serveur']; ?></a></div></td>
<td><div align="left" class="Style10"><?php echo $row_rs['date_doc']; ?></div></td>
</tr> <?php } while ($row_rs = mysql_fetch_assoc($rs)); ?>
</table>
<p> </p></td>
</tr>
</table>
<p> </p></td>
</tr>
</table>
</body>
</html>
<?php
mysql_free_result($rs);
?>