fomalhaut
Member
- Messages
- 107
- Reaction score
- 0
- Points
- 16
Hello all. I've a problem in php.
On a php page, I get the user's informations (user, password, etc...). On another php page, the user can change his password or his profile, but I don't want have to ask him again his user name.
I've tried with session_start(); on the top of the first page, and then $_SESSION['userid']=user_value; but when I retrieve the $_SESSION value in the next php page, there is nothing !
How do I do that ?
1st PHP:
<?php
session_start();
?>
...
<link rel=stylesheet href="the.css" type="text/css">
</head>
<body>
<?php
$con = mysql_connect("localhost", "ident_name", "ident_pw");
$db = "db_ayantdroit";
if (!$con) {die('Connection impossible : ' . mysql_error());}
mysql_select_db($db, $con);
$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;
...
2nd PHP :
<html><head><title>Gestion du mot de passe</title>
<link rel=stylesheet href="the.css" type="text/css">
</head>
<body>
<div class="flot"><center>
<form action="thePass.php" method="post">
Mot de Passe actuel :<br /><input type="password" name="upass" /><br />
Nouveau Mot de Passe :<br /><input type="password" name="nupass1" /><br />
Vérification du Nouveau Mot de Passe :<br /><input type="password" name="nupass2" /><br />
<input type="submit" name="submit" />
</form></center>
</div>
<?php
$ut=$_SESSION['util'];
echo 'début du php de gesPass.php<br />';
echo "nom d'utilisateur = /".$_POST['utilisateur']."/<br />";
echo 'suite du php de gesPass.php';
...
and this is the result of the echoes :
début du php de gesPass.php
nom d'utilisateur = //
suite du php de gesPass.php
Thanks for your help.
On a php page, I get the user's informations (user, password, etc...). On another php page, the user can change his password or his profile, but I don't want have to ask him again his user name.
I've tried with session_start(); on the top of the first page, and then $_SESSION['userid']=user_value; but when I retrieve the $_SESSION value in the next php page, there is nothing !
How do I do that ?
1st PHP:
<?php
session_start();
?>
...
<link rel=stylesheet href="the.css" type="text/css">
</head>
<body>
<?php
$con = mysql_connect("localhost", "ident_name", "ident_pw");
$db = "db_ayantdroit";
if (!$con) {die('Connection impossible : ' . mysql_error());}
mysql_select_db($db, $con);
$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;
...
2nd PHP :
<html><head><title>Gestion du mot de passe</title>
<link rel=stylesheet href="the.css" type="text/css">
</head>
<body>
<div class="flot"><center>
<form action="thePass.php" method="post">
Mot de Passe actuel :<br /><input type="password" name="upass" /><br />
Nouveau Mot de Passe :<br /><input type="password" name="nupass1" /><br />
Vérification du Nouveau Mot de Passe :<br /><input type="password" name="nupass2" /><br />
<input type="submit" name="submit" />
</form></center>
</div>
<?php
$ut=$_SESSION['util'];
echo 'début du php de gesPass.php<br />';
echo "nom d'utilisateur = /".$_POST['utilisateur']."/<br />";
echo 'suite du php de gesPass.php';
...
and this is the result of the echoes :
début du php de gesPass.php
nom d'utilisateur = //
suite du php de gesPass.php
Thanks for your help.