Open file based on user input - follow up question
Posted: Fri May 30, 2008 2:40 pm
Using the following code works for most of my scenarios but I've run into an issue. I have two users named Mary, each with a different ticket number. Using the following code, only the 2nd one can retrieve her files. I assume it is a case of last in resetting the variable $users and that is why Mary 111111 fails the test.
The file name is the user's name and ticket number, so the only issue is the logic to check more than the name. Possibly create a variable that is the first name and ticket?
Suggestions on how to code for this condition?
The file name is the user's name and ticket number, so the only issue is the logic to check more than the name. Possibly create a variable that is the first name and ticket?
Suggestions on how to code for this condition?
Code: Select all
<?
if($_POST['username'])
{
$users['mary']='111111';
$users['mary']='222222';
$users['dick']='555555';
$users['harry']='777777';
$file['mary']='mary111111.htm';
$file['mary']='mary222222.htm';
$file['dick']='dick.htm';
$file['harry']='harry.htm';
if($users[$_POST['username']]==$_POST['pincode'])
{
print "SUCCESS";
print file_get_contents($file[$_POST['username']]);
die();
}
}
?>
<form method="post">
<input name="username" value="first name" size="25" maxlength="12">
<input name="pincode" value="ticket" size="25" maxlength="6">
<input name="Search" type="submit" id="Search" value="Search">
</form>