Jump to content

[SOLVED] Arrays And If Statements...?


tarun

Recommended Posts

users.txt

user1|||pass1
user2|||pass2
user3|||pass3

 

 

login.php

<?php
$user  =  $_POST["u"];
$pass  =  $_POST["p"];
$db = file("users.txt");

foreach($db as $key => $val) { $data[$key] = explode("|||", $val); }

for($k = 0; $k < sizeof($db); $k++) { 
$u = $data[$k][0];
$p = $data[$k][1];

if ( $u == "$user" ) {
if ( $p == "$pass" ) { echo 'You Are Now Logged In As: '.$u.''; }
else { echo 'Username And Password Do Not Match'; }
}


}
?>

 

The If Statement Doesn't Work

I Get The Error:

"Username And Password Do Not Match"

Even If The Username And Password Are Actually Right

 

 

 

AnyHelp?

Thnx,

Tarun

Link to comment
https://forums.phpfreaks.com/topic/46476-solved-arrays-and-if-statements/
Share on other sites

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.