Saving logon in Sessions

#1

I have a script like this:

[code]<?php
session_start();
// Define your username and password
$username = “username”;
$password = “password”;
$_SESSION[‘txtUsername’] = $_POST[‘txtUsername’];
$_SESSION[‘txtPassword’] = $_POST[‘txtPassword’];
if ($_SESSION[‘txtUsername’] != $username || $_SESSION[‘txtPassword’] != $password) {

?>

Login

Username:

<p><label for="txtpassword">Password:</label>
<br /><input type="password" title="Enter your password" name="txtPassword" /></p>

<p><input type="submit" name="Submit" value="Login" /></p>
<?php } else { //--------------------------------------------------------------------------------------- $filename = $_GET['filename']; if (empty($filename)) { ?> <?php }

else
{
if (strpos($filename,".zip") >= 1)
{
exec(‘unzip $filename’,$ret);
echo “Successful unzipping”;
session_destroy();
}
elseif ((strpos($filename,".tgz") >= 1) || (strpos($filename,".tar.gz") >= 1))
{
exec(‘tar -xzf $filename’,$ret);
echo “Successful untargzing”;
session_destroy();
}
else
{
?>

<?php } } } ?>[/code]

The only part we need to worry about is logging in. The problem is that After I logon and use the text box to submit my filename, it takes me to the login screen again. I thought I had solved this by using session variables that only expire after a successfull uncompressing, but apparently I was wrong. Help!

#2

Here’s the problem:

[php]
$_SESSION[‘txtUsername’] = $_POST[‘txtUsername’];
$_SESSION[‘txtPassword’] = $_POST[‘txtPassword’];
[/php]

When submitting a filename, what keeps the script from overwriting the currently stored SESSION values with new POST values (which are empty, since none were defined on the insert filename form)?

#3

Thank you. That workde well.