Jump to content

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!");

}

?>

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.