Jump to content

Help with login.. works at home but not at school


TheJoey

Recommended Posts

<?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..

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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".

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.