ciao ragazzi ho un problema, sono alle prime armi e non riesco a trovare soluzione.
allora ho creato una pagina SECRET.PHP che per essere visualizzata ha bisogno di un nome utente e password. Faccio questo usando le sessioni attraverso un file auth.inc.php che esamina la passoword attraverso LOGIN.PHP
Se si viene identificati e il nome utente e password sono corretti, visualizzo la pagina
che contiene un modulo.
adesso in questo modulo voglio che viene visualizzato la password che faccio inserire all'inizio,...
.... ma non ci riesco
vi metto i listati:
listato auth.inc.php
<?php
// start or continue session
session_start();
if (!isset($_SESSION['logged'])) {
header('Refresh: 5; URL=login.php?redirect=' . $_SERVER['PHP_SELF']);
echo '
You will be redirected to the login page in 5 seconds.</p>';
echo '
If your browser doesn\'t redirect you properly automatically, ' .
'<a href="login.php?redirect=' . $_SERVER['PHP_SELF'] .
'">click here</a>.</p>';
die();
}
?>
Listato LOGIN.PHP
<?php
session_start();
// filter incoming values
$username = (isset($_POST['username'])) ? trim($_POST['username']) : '';
$password = (isset($_POST['password'])) ? $_POST['password'] : '';
$redirect = (isset($_REQUEST['redirect'])) ? $_REQUEST['redirect'] :
'main.php';
if (isset($_POST['submit'])) {
if (!isset($_SESSION['logged']) || $_SESSION['logged'] !=1) {
if (!empty($_POST['username']) && $_POST['username'] == 'prova' &&
!empty($_POST['password']) && $_POST['password'] == '123456789') {
$_SESSION['username'] = $username;
$_SESSION['logged'] = 1;
$_SESSION['admin_level'] = $row['admin_level'];
header ('Refresh: 5; URL=' . $redirect);
echo '
You will be redirected to your original page request.</p>';
echo '
If your browser doesn\'t redirect you properly automatically, ' .
'click here.</p>';
die();
} else {
$_SESSION['username'] = '';
$_SESSION['logged'] = 0;
$error = '
You have supplied an invalid username and/or ' .
'password! Please <a href="register.php">click here ' .
'to register</a> if you have not done so already.</p>';
}
}
}
?>
<html>
<head>
<title>Login</title>
</head>
<body>
<?php
if (isset($error)) {
echo $error;
}
?>
<form action="login.php" method="post">
<table>
<tr>
<td>Username:</td>
<td><input type="text" name="username" maxlength="20" size="20"
value="<?php echo $username; ?>"/></td>
</tr><tr>
<td>Password:</td>
<td><input type="password" name="password" maxlength="20" size="20"
value="<?php echo $password; ?>"/></td>
</tr><tr>
<td> </td>
<td>
<input type="hidden" name="redirect" value="<?php echo $redirect ?>"/>
<input type="submit" name="submit" value="Login"/>
</tr>
</table>
</form>
</body>
</html>
pagina segret.php
<?php
include 'auth.inc.php';
$password = $_POST['password'];
?>
<html>
<head>
<title>Secret</title>
</head>
<body>
<table border="0" width="49%" cellpadding="2" id="table1" height="227">
<tr>
<td height="124">
<h1>You've found my secret!</h1>
</td>
<td height="124"></td>
</tr>
<tr>
<td>
<form method="POST" enctype="multipart/form-data">
</p>
codice abbonamento: </p>
<?php
echo $_password;
?>
<select size="1" name="D1">
<option>teo</option>
<option>marco</option>
<option>maria</option>
</select></p>
</p>
<input type="file" name="F1" size="20"></p>
<input type="submit" value="Invia" name="B1"><input type="reset" value="Reimposta" name="B2"></p>
</form>
</td>
<td></td>
</tr>
</table>
</body>
</html>