salve a tutti io ho il mio login e il checklogin in php che mi avvia la sessione password e nome
ma quando vado in un altra pagina come faccio a far si che mi legga il nome utente salvato nella sessione?
metto i file
login.php
Codice PHP:
<html>
<head>
<title>
Benvenuto nel forum
</title>
</heAD>
<body>
<div id="login_form" style="border:1px solid; background:grey; height:120px; width:190px; float:right">
<form action="../checklogin.php" method="post">
<label>Username:<input type="text" name="user"></label>
<label>Password:<input type="password" name="password"></label>
<input type="submit" name="submit" value="Login" >
</form>
</div>
</body>
</html>
checklogin.php
Codice PHP:
<?php
include ("configlocale.php");
//start session
session_start();
session_regenerate_id(TRUE);
//variabili
$users = htmlspecialchars($_POST['user']);
$passwords = md5(htmlspecialchars($_POST['password']));
$query = "SELECT * FROM users WHERE user='$users' AND password='$passwords'";
$result = mysql_query($query, $conn);
if(mysql_num_rows($result)) {
//se è loggato creo la sessione
$_SESSION['user'] = $users;
$_SESSION['password'] = $passwords;
echo ('
<html>
<body>
Loggato
[url="index.php"]Clicca qui[/url]
</body>
</html>
<?php
');
} else {
print("Login invalido.");
exit;
}
?>