TheJoey Posted October 15, 2009 Share Posted October 15, 2009 <?php session_start(); $username = $_POST['username']; $password = $_POST['password']; $lines = file("data/users.txt",FILE_IGNORE_NEW_LINES); // read the lines into an array $find = "$username:$password"; // form a string like you expect it to be in the array if(in_array($find,$lines)){ $_SESSION['loginsuccessfull'] = true; # If successfull header("location: loginsuccess.php"); # redirect to this page } else { # Else redirect to header("location: loginunsuccess.php"); # this page } ?> im completly stuck and have no idea why its not working.. Quote Link to comment https://forums.phpfreaks.com/topic/177730-help-with-login-works-at-home-but-not-at-school/ Share on other sites More sharing options...
RussellReal Posted October 15, 2009 Share Posted October 15, 2009 school doesn't support cookies maybe? and your session id is storing in cookies unless you set it up to work with GET vars Quote Link to comment https://forums.phpfreaks.com/topic/177730-help-with-login-works-at-home-but-not-at-school/#findComment-937138 Share on other sites More sharing options...
TheJoey Posted October 15, 2009 Author Share Posted October 15, 2009 i have a script that uses this <?php session_start(); $username = $_POST['username']; $password = $_POST['password']; if ($username == 'super' && $password == 'super') { $_SESSION['success'] = true; header("location: adminsuccess.php"); } else { header("location: adminunsuccess.php"); } ?> and it works fine i just keep getting refered to unsuccess. Quote Link to comment https://forums.phpfreaks.com/topic/177730-help-with-login-works-at-home-but-not-at-school/#findComment-937144 Share on other sites More sharing options...
TheJoey Posted October 15, 2009 Author Share Posted October 15, 2009 is there mabye another way i can go about doing this. Quote Link to comment https://forums.phpfreaks.com/topic/177730-help-with-login-works-at-home-but-not-at-school/#findComment-937170 Share on other sites More sharing options...
TheJoey Posted October 15, 2009 Author Share Posted October 15, 2009 Could it be a different version of php? Quote Link to comment https://forums.phpfreaks.com/topic/177730-help-with-login-works-at-home-but-not-at-school/#findComment-937342 Share on other sites More sharing options...
cags Posted October 15, 2009 Share Posted October 15, 2009 Are you certain it's the redirect on that page that is redirecting your client and not code on your adminsuccess.php page? Quote Link to comment https://forums.phpfreaks.com/topic/177730-help-with-login-works-at-home-but-not-at-school/#findComment-937349 Share on other sites More sharing options...
TheJoey Posted October 15, 2009 Author Share Posted October 15, 2009 works fine at home but when i take it to school theres issues Quote Link to comment https://forums.phpfreaks.com/topic/177730-help-with-login-works-at-home-but-not-at-school/#findComment-937351 Share on other sites More sharing options...
cags Posted October 15, 2009 Share Posted October 15, 2009 Whats your point? We already know that as you wrote it in the topic title. As has already been pointed out to you the most likely problem is that the client at school doesn't support cookies. If your adminsuccess.php has any redirects on it for if $_SESSION['success'] != true, which I would sincerely hope it has. If the client PC doesn't have cookies enabled then as soon as you arrive at adminsuccess.php you would be redirected away. Quote Link to comment https://forums.phpfreaks.com/topic/177730-help-with-login-works-at-home-but-not-at-school/#findComment-937352 Share on other sites More sharing options...
TheJoey Posted October 15, 2009 Author Share Posted October 15, 2009 thats where im confused, my admin is working fine, its my registered users that cant login. And there using both very similar scripts and both are using sessions. Quote Link to comment https://forums.phpfreaks.com/topic/177730-help-with-login-works-at-home-but-not-at-school/#findComment-937353 Share on other sites More sharing options...
cags Posted October 15, 2009 Share Posted October 15, 2009 If your admin is working fine, and it's your registered users that can't login, why in gods name did you post a section of code which blatantly appears to refer to the admin with the title "Help with login.. works at home but not at school". Quote Link to comment https://forums.phpfreaks.com/topic/177730-help-with-login-works-at-home-but-not-at-school/#findComment-937361 Share on other sites More sharing options...
TheJoey Posted October 15, 2009 Author Share Posted October 15, 2009 the first code snippet is the code that wont work.. the second snippet is the code that does work. Quote Link to comment https://forums.phpfreaks.com/topic/177730-help-with-login-works-at-home-but-not-at-school/#findComment-937370 Share on other sites More sharing options...
cags Posted October 15, 2009 Share Posted October 15, 2009 Ah right, I see. The code that's at fault is undoubtedly the code that isn't in both scripts then... $lines = file("data/users.txt",FILE_IGNORE_NEW_LINES); // read the lines into an array $find = "$username:$password"; // form a string like you expect it to be in the array if(in_array($find,$lines)){ Have you tried print_r($lines); to see what the $lines array actually contains? Quote Link to comment https://forums.phpfreaks.com/topic/177730-help-with-login-works-at-home-but-not-at-school/#findComment-937376 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.