Author Topic: cant check file extension correctly  (Read 1507 times)

0 Members and 1 Guest are viewing this topic.

Offline Jaysonic

  • Fanatic
  • Posts: 3,332
  • Gender: Male
  • 8548863
    • View Profile
    • I Am Lewy Babes
Re: cant check file extension correctly
« Reply #15 on: November 11, 2006, 10:26:27 PM »
no no no. thats looking for a file which is blank. you havnt set $Uname yet. as you can see in your code.
try this:
Code: [Select]
<?PHP
 $Uname='';
 $Pass='';
 $contents='';

 if ($_REQUEST['Uname'] != "") {
  $Uname = $_REQUEST['Uname'];
 } else {
die('You need both a Username and password to login');
 }



 if ($_REQUEST['Pass'] != "") {
  $Pass = $_REQUEST['Pass'];
 } else {
  die('You need both a Username and password to login');
 }



if(!file_exists("imgs/".$Uname.".nam")){
echo "Username does not exist, please check that capslock is not on and that your entry was spelled correctly.";
}else{
 $fp = fopen("imgs/".$Uname.".nam","rb");
 $contents = fread($fp, filesize("imgs/".$Uname.".nam"));
 fclose($fp);

 $pieces = explode(" ", $contents);

 if ($pieces[2] == md5($Pass)) {
setcookie('User',$Uname,time()+(60*60));
 } else {
die ('Sorry the password username combanation does not exist');
 }

header("Location: http://" . $_SERVER['HTTP_HOST'] . rtrim(dirname($_SERVER['PHP_SELF']), '/\\') . "/index.php");
}
?>

because now $Uname is set, and we can check if the file exists.
Good luck with your coding.
Jason ~ ProjectFear ~ Jaysonic (and variations of... :))