No.
The issue is that this (psuedo) code doesn't work:
$rows[ ] = "eawf:otherstuff\n";
$testdata = "eawf";
foreach($rows as $row){
$data = explode(":",$row);
if($data[0] == $testdata){
header("Location: $self");
}
}
while this one does work:
$rows[ ] = "eawf:otherstuff\n";
$testdata = "eawf";
foreach($rows as $row){
$data = explode(":",$row);
if($data[0] == $testdata){
$flag = true
}
}
if(isset($flag)){
header("Location: $self");
}
actually does work. So the question is, WHY doesn't the first code snippet work?
The psuedo code for the above is:
Form submit provides input vars for userid and password.
read all records from .htpasswd and load to an array ($rows)
process array one element at a time
parse array vars via ":" character.
if userid from form matches the userid from .htpassword:
reload the page with a get var loaded with an error message.
else process next record.
I can[t find anything online indicating that the foreach loop is not able to be broken by issuing the header() function, which, at least to my way of thinking, should stop program code execution by simply reloading the page again. What ends up happening is that the program continues to run and the header statement is not executed.
Hope this makes sense?