I'm having a little problem with my PHP-code. I want to create a site which has different directories. Every directories has a file named pass (not .txt or something) with the value of the directories password. So if the pass-file doesn't exist the group will not exist. But even if the group exists it still says the group doesn't exist and I can't fopen the file either, but I can locate to it. Here's my code:
<?php
$name = $_POST['name'];
$group = $_POST['group'];
$pass = $_POST['pass'];
$filename = '/groups/' . $group . '/pass';
if(file_exists($filename)){
$handle = fopen($filename) or die("can't open file");
$hoi = fread($handle, filesize($filename));
fclose($handle);
if ($pass === $hoi){
session_start();
$_SESSION['name'] = $name;
header('Location: http://www.google.com');
}
else{
echo 'Password is wrong!';
}
}
else{
echo 'Group does not exist!';
}
?>
All POST-data is correct btw. Thanks for your help!