Jump to content

need help with my login system


Jay77710

Recommended Posts

My login system without mysql isn't validating my login info right. I'll register, then go to the login page. My problem is, when I login (I'm using the "test" username and "test" password I registered with. And I don't think I'm typing it in wrong) it says that my username and password do not match.

 

here is the login.php that the login script uses

<?php

if (isset ($_POST['submit'])) {

$loggedin = FALSE;

$fp = fopen ( 'users.txt', 'rb' );

while ( $line = fgetcsv ($fp, 100, "\t")) {

if ( ($line[0] == $_POST['username']) AND ($line[1] == crypt ($_POST['password'], $line[1]) ) ) {

$loggedin = TRUE;

break;

}

}

}

if ($loggedin) {

print ("You are now logged in!");

} else {

print ("The username and password did not match!");

}

?>

 

and this is the user.txt that it pulls the info from

test	$1$iIujXdC1$hnHez0KjeD7jch0Xz8yH/1	11988036902649

 

if you can help me figure this out, that would be great.

Link to comment
https://forums.phpfreaks.com/topic/83539-need-help-with-my-login-system/
Share on other sites

try this

<?php

if (isset ($_POST['submit'])) {

$username=$_POST['username'];

$password=$_POST['password'];

$loggedin = FALSE;

$fp = fopen ( 'users.txt', 'rb' );

while ( $line = fgetcsv ($fp, 100, "\t")) {

if ( ($line[0] == crypt ($password), $line[1]) ) ) {

$loggedin = TRUE;

break;

}

}

}

if ($loggedin) {

print ("You are now logged in!");

} else {

print ("The username and password did not match!");

}

?>

try

<?php

if (isset ($_POST['submit'])) {

$username=$_POST['username'];

$password=$_POST['password'];

$loggedin = FALSE;

$fp = fopen ( 'users.txt', 'rb' );

while ( $line = fgetcsv ($fp, 100, "\t")) {

if ( ($line[1] == crypt ($password) ) {

$loggedin = TRUE;

break;

}

}

}

if ($loggedin) {

print ("You are now logged in!");

} else {

print ("The username and password did not match!");

}

?>

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.