Okay, I have debugged, corrected some things, & see where the problem is.
I have tested this script in Firefox2, Firefox1, Firebird, IE7, Opera, Safari, Netscape 6.2, 7.2, 8, & 9. These all did exactly the same thing in num2.php, & printed the correct message based on the username I entered. I tested a number of different usernames.
IE6 & IE5 went to the num2.php page but printed nothing.
In my tests I made sure that IE5 & IE6 had the right username in num1.php in the accessGranted function & both did, so I am concluding that IE5 & IE6 are not getting the username in num2.php, but I don't understand why.
somepasswordfile.txt
account1,password1,Location: http://www.somesite.com/account1.php
account2,password2,Location: http://www.somesite.com/account2.php
account3,password3,Location: http://www.somesite.com/account3.php
account4,password4,Location: http://www.somesite.com/account4.php
account5,password5,Location: http://www.somesite.com/account5.php
account6,password6,Location: http://www.somesite.com/account6.php
account7,password7,Location: http://www.somesite.com/account7.php
account8,password8,Location: http://www.somesite.com/account8.php
account9,password9,Location: http://www.somesite.com/account9.php
account10,password10,Location: http://www.somesite.com/account10.php
num1.php
<?php
session_start();
extract( $_POST );
if ( !$USERNAME || !$PASSWORD ) {
accessDenied();
}
if ( !( $file = fopen( "somepasswordfile.txt", "r" ) ) ) {
$errorMessage = 'Error<br />Could not open password file.';
die();
}
$userVerified = 0;
while ( !feof( $file ) && ($userVerified < 1) ) {
$line = fgets( $file, 200 );
$line = chop( $line );
$field = explode( ",", $line );
if ($USERNAME == $field[ 0 ] ) {
if ( checkPassword( $PASSWORD, $field[1] ) == true ) {
$userVerified=1;
accessGranted( $USERNAME,$field[2] ); }
else
accessDenied();
}
}
fclose( $file );
if ($USERNAME != $field[0]) {
accessDenied();
}
function checkPassword( $userpassword, $filedata )
{
if ( $userpassword == $filedata )
return true;
else
return false;
}
function accessGranted( $name,$link ) {
$_SESSION['username'] = $name;
header($link);
}
function accessDenied() {
header('Location: http://www.somesite.com/clientlogin.html');
}
?>
<html><head></head><body></body></html>
num2.php
<?php
session_start();
$client = 'clientname';
if ($_SESSION['username'] == $client)
{
echo "Valid session ";
echo $_SESSION['username'];
}
else {
echo $_SESSION['username'];
}
?>
<html><head></head><body></body></html>
😕