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

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.

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.

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

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.