Twentyoneth Posted February 1, 2007 Share Posted February 1, 2007 I am creating a simple login system....each member has a folder and in the folder is a password file (password.php), which will contain something like this: <?php $pass = "password"; ?> and When you log in, this is the code that checks to see if the input password is the same as the one in the file...the problem is, when I include that file, it wont read it, help? <?php include("up.php"); $iuser = $_POST['user']; $ipass = $_POST['pass']; $pull = $iuser . "/info/password.php"; include("$pull"); if($ipass == $pass) { setcookie("UserName", $user, time()+3600, "/", false); setcookie("Password", $pass, time()+3600, "/", false); echo "<META HTTP-EQUIV='Refresh' CONTENT='3; URL=http://12.27.247.70:8000/New/" . $user . "'>Logged In.<br><br><a href='http://12.27.247.70:8000/New/" . $iuser . "'>Home</a>"; } else { echo "<META HTTP-EQUIV='Refresh' CONTENT='3; URL=http://12.27.247.70:8000/New'>Invalid username or password.<br><br><a href='http://12.27.247.70:8000/New'>Home</a>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/36604-include-function-help/ Share on other sites More sharing options...
.josh Posted February 1, 2007 Share Posted February 1, 2007 well this might be a dumb answer, but you say the filename is password.php but in your code you include up.php. Did you mean up.php or is that the problem? edit: whoops. didn't see your $pull thingy..sec Quote Link to comment https://forums.phpfreaks.com/topic/36604-include-function-help/#findComment-174349 Share on other sites More sharing options...
JasonLewis Posted February 1, 2007 Share Posted February 1, 2007 include it like this: include($pull); it may or may not change the outcome. Quote Link to comment https://forums.phpfreaks.com/topic/36604-include-function-help/#findComment-174356 Share on other sites More sharing options...
Twentyoneth Posted February 1, 2007 Author Share Posted February 1, 2007 Same outcome, anyother solutions, or workarounds? Quote Link to comment https://forums.phpfreaks.com/topic/36604-include-function-help/#findComment-174363 Share on other sites More sharing options...
Jessica Posted February 1, 2007 Share Posted February 1, 2007 This is something that really should be in a database. :/ What happens when you print $pull? Is the value what you expect? Are all these user folders in the same directory as this file? You may need to adjust the path. So right after you include it, if you print $pass, it is empty? Quote Link to comment https://forums.phpfreaks.com/topic/36604-include-function-help/#findComment-174370 Share on other sites More sharing options...
Twentyoneth Posted February 1, 2007 Author Share Posted February 1, 2007 It is empty, and the path is the same for all of the files....(I would use a database, but I have experience, I have no idea how to do it :S) Quote Link to comment https://forums.phpfreaks.com/topic/36604-include-function-help/#findComment-174372 Share on other sites More sharing options...
JasonLewis Posted February 1, 2007 Share Posted February 1, 2007 try going like this is the password folder: $user['password'] = "password"; then above the include have this: $user = array(); include($iuser . "/info/password.php"); echo $user['password']; see if that works for you. Quote Link to comment https://forums.phpfreaks.com/topic/36604-include-function-help/#findComment-174381 Share on other sites More sharing options...
Twentyoneth Posted February 1, 2007 Author Share Posted February 1, 2007 It will not include the file at all :S Quote Link to comment https://forums.phpfreaks.com/topic/36604-include-function-help/#findComment-174382 Share on other sites More sharing options...
bibby Posted February 1, 2007 Share Posted February 1, 2007 Here's some a test for some possible errors. <? $inc = $iuser . "/info/password.php"; if (file_exists($inc)) { if ( (fileperms($inc) & 4) == 4) include($inc); else echo "dood, you don't have read permission for this file. (User: Other)"; } else echo "dood, check this path. IS it right? ->".$inc; ?> Quote Link to comment https://forums.phpfreaks.com/topic/36604-include-function-help/#findComment-174408 Share on other sites More sharing options...
bibby Posted February 1, 2007 Share Posted February 1, 2007 You might want to try this too... Some servers want their includes to begin from root. $inc = $_SERVER['DOCUMENT_ROOT'].'/'.$iuser."/info/password.php"; Quote Link to comment https://forums.phpfreaks.com/topic/36604-include-function-help/#findComment-174410 Share on other sites More sharing options...
yzerman Posted February 1, 2007 Share Posted February 1, 2007 your problem seems to be your choice of variable names. You have set the $_POST data ($_POST['user'] and $_POST['pass']) names to the same variables you are pulling your password from. What I mean is, $user and $pass are the exact same as $_POST['user'] and $_POST['pass'] try changing your variable names (i.e. $p = 'PASSWORD') and see if that works better. Quote Link to comment https://forums.phpfreaks.com/topic/36604-include-function-help/#findComment-174412 Share on other sites More sharing options...
.josh Posted February 1, 2007 Share Posted February 1, 2007 your problem seems to be your choice of variable names. You have set the $_POST data ($_POST['user'] and $_POST['pass']) names to the same variables you are pulling your password from. What I mean is, $user and $pass are the exact same as $_POST['user'] and $_POST['pass'] try changing your variable names (i.e. $p = 'PASSWORD') and see if that works better. $user and $pass are not the same as $_POST['user'] and $_POST['pass'], unless you have your register_globals set to ON, which you shouldn't. Quote Link to comment https://forums.phpfreaks.com/topic/36604-include-function-help/#findComment-174613 Share on other sites More sharing options...
ted_chou12 Posted February 1, 2007 Share Posted February 1, 2007 <?php if(isset($_POST['submit'])){//do you have this already? because it is essential to pass data from form to php... include("up.php"); $iuser = $_POST['user']; echo $iuser;//double check if the string is expected $ipass = $_POST['pass']; echo $ipass;//double check if the string is expected include("$iuser/info/password.php");//I dont think pausing the echo is necassary continued...//below stays the same }//dont forget to close the isset... ?> If the echoes dont come out right, then there is no point continuing further, so get your POST successfully sorted out first. Ted Quote Link to comment https://forums.phpfreaks.com/topic/36604-include-function-help/#findComment-174626 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.