fomalhaut
Member
- Messages
- 107
- Reaction score
- 0
- Points
- 16
Hello.
I set a user value throught a form (that's ok).
And I want this user to be visible in the "input form" during his whole session.
here's the form:
I try to set the
but the value I want to set is a Php variable! How can I do ?
There is the beginning of the Php code:
Here I'would like to have something like this:
That's the following Php code:
Thank you for help me.
I set a user value throught a form (that's ok).
And I want this user to be visible in the "input form" during his whole session.
here's the form:
HTML:
<form action="index.php" method="post">
Identifiant :<br /><input type="text" name="utilisateur" id="utilisateur" /><br />
Mot de Passe :<br /><input type="password" name="upass" /><br />
<input type="submit" name="submit" /><br />
<input type="submit" name="dcnx" value="déconnexion" id="dcnx" />
</form>
Code:
document.getElementById('utilisateur').value
There is the beginning of the Php code:
PHP:
<?php
if (isset($_POST['dcnx'])) {
$oldUtil = $_SESSION['util'];
unset($_SESSION['util']);
unset($_SESSION['service']);
?><script type="text/javascript">
document.getElementById('dcnx').style.visibility = 'hidden';
</script><?php
echo '<center>' . $oldUtil . ', ton identifiant est maintenant déconnecté</center>';
}
$con = mysql_connect("localhost", "jyc_testeur", "a1b2c3d4e5f6");
$db = "jyc_ayantdroit";
if (!$con) {die('Connection impossible : ' . mysql_error());}
mysql_select_db($db, $con);
if (isset($_SESSION['util'])) {
$ut = $_SESSION['util'];
$service = $_SESSION['service'];
$sql2 = "SELECT * FROM menu_droit WHERE service <= '" . $service . "'";
include ('menu.php');
}
else {
$ut = $_POST['utilisateur'];
$pa = $_POST['upass'];
$sql = "SELECT * FROM ayant_droit WHERE utilisateur = '" . $ut . "'";
$result = mysql_query($sql);
if (mysql_num_rows($result) > 0) { // l'utilisateur existe dans la base
while($row = mysql_fetch_array($result)) {
if ($row['upass'] == $pa) { // password valide, on charge le menu correspondant au niveau de service
$_SESSION['util']=$ut;
$motdepaserrone = ' ';
$service = $row['service'];
$_SESSION['service']=$service;
?><script type="text/javascript">
document.getElementById('dcnx').style.visibility = 'visible';
Code:
[B]document.getElementById('utilisateur').value = $ut;[/B]
That's the following Php code:
PHP:
</script><?php
$sql2 = "SELECT * FROM menu_droit WHERE service <= '" . $service . "'";
}
else { // password invalide
$motdepaserrone = "<div class='flot'><br /><br /><br /><br /><br /><br /><center class='rouge'>Mot de passe erroné</center></div>";
$sql2 = "SELECT * FROM menu_droit WHERE service= '000'";
}
include ('menu.php');
}
}
else { /* l'utilisateur n'existe pas dans la base
on charge le menu par défaut */
?><script type="text/javascript">
document.getElementById('dcnx').style.visibility = 'hidden';
</script><?php
$sql2 = "SELECT * FROM menu_droit WHERE service= '000'";
include ('menu.php');
}
}
?>
Thank you for help me.