Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
If statement that doesn't work?
Old 02-28-2008, 07:31 PM If statement that doesn't work?
Arenlor's Avatar
Ultra Talker

Posts: 462
Name: Jerod Lycett
Location: /home/arenlor
Trades: 0
I got pretty interested in the idea of using a text file as a database, want to see if it can be reliably used, apparently something is broken about it. Code is as follows.
PHP Code:
<?php session_start();
$user $_POST['user'];
$pass $_POST['pass'];
$msg $_GET['msg'];
if(
$user != '' && $pass != ''){
    
$text file('./tmp/users.txt');
    foreach(
$text as $line){
        list(
$name,$code) = split('::'$line);
        if(
$user == $name && md5($pass) == $code){$_SESSION['user'] = $user$_SESSION['pass'] = $passheader('Location: index.php');exit;}
        echo 
'<p>Line: '.$line.'</p><p>Given: '.$user.'::'.md5($pass).'</p>';
}
echo 
"Username or password bad, please try again.";
}
?>
Contents of users.txt:
Quote:
test::098f6bcd4621d373cade4e832627b4f6
Arenlor::1f3870be274f6c49b3e31a0c6728957f
user::1a1dc91c907325c69271ddf0c944bc72
atest::098f6bcd4621d373cade4e832627b4f6
(it has a new line at that bottom that won't show here)
The output given is:
Quote:
Line: test::098f6bcd4621d373cade4e832627b4f6

Given: Arenlor::1f3870be274f6c49b3e31a0c6728957f

Line: Arenlor::1f3870be274f6c49b3e31a0c6728957f

Given: Arenlor::1f3870be274f6c49b3e31a0c6728957f

Line: user::1a1dc91c907325c69271ddf0c944bc72

Given: Arenlor::1f3870be274f6c49b3e31a0c6728957f

Line: atest::098f6bcd4621d373cade4e832627b4f6

Given: Arenlor::1f3870be274f6c49b3e31a0c6728957f
Username or password bad, please try again.
Any ideas? Also before anyone freaks about password md5s being given out, it's in this order, test apple pass test. Using any decrypter site they can be easily found and it's only a test, same thing with using users.txt only a test of the system and if I ever implimented it I'd probably do a good bit more to it for security including renaming the file.
__________________
PHP Code:
<?php echo "Hello World"?>
HTML Code:
<html><head><title>Hello World</title></head><body><p>Hello World</p></body></html>
Arenlor is offline
Reply With Quote
View Public Profile Visit Arenlor's homepage!
 
 
Register now for full access!
Old 02-28-2008, 10:28 PM Re: If statement that doesn't work?
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
Your use of:
PHP Code:
list($name,$code) = split('::'$line); 
is wrong because list() assigns key => value from each array item. You want something like the following:

PHP Code:
$split split('::'$line);
$name $split[0];
$code $split[1]; 
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 02-29-2008, 12:13 AM Re: If statement that doesn't work?
Arenlor's Avatar
Ultra Talker

Posts: 462
Name: Jerod Lycett
Location: /home/arenlor
Trades: 0
I hadn't know that, thanks.
__________________
PHP Code:
<?php echo "Hello World"?>
HTML Code:
<html><head><title>Hello World</title></head><body><p>Hello World</p></body></html>
Arenlor is offline
Reply With Quote
View Public Profile Visit Arenlor's homepage!
 
Reply     « Reply to If statement that doesn't work?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.13070 seconds with 12 queries