Password

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
alex_cunningham
Forum Newbie
Posts: 13
Joined: Tue Jun 24, 2008 6:34 pm

Password

Post by alex_cunningham »

i need a php code that will read all the usernames and passwords out of a txt file

for example:
User name:password
alex_cunningham
Forum Newbie
Posts: 13
Joined: Tue Jun 24, 2008 6:34 pm

Re: Password

Post by alex_cunningham »

but i also need a sign up how do i edit the text file in a php code
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Password

Post by John Cartwright »

use file() to load each line into an array, foreach() to traverse the array, and explode() to seperate the elements on the colon.

Also, please read our forum descriptions. This is the second time you've posted in the wrong forum.

Moved to PHP-Code.
alex_cunningham
Forum Newbie
Posts: 13
Joined: Tue Jun 24, 2008 6:34 pm

Re: Password

Post by alex_cunningham »

??? 8O can i get the code in English please
Last edited by alex_cunningham on Tue Jun 24, 2008 11:22 pm, edited 1 time in total.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Password

Post by John Cartwright »

alex_cunningham wrote:??? 8O can i get that in English please
You got it in english. I'm not here to write the code for you, I'm here to offer assistance. Try reading the links I provided first.
alex_cunningham
Forum Newbie
Posts: 13
Joined: Tue Jun 24, 2008 6:34 pm

Re: Password

Post by alex_cunningham »

you know hes the kind of people who drive people away from the forum
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Password

Post by John Cartwright »

alex_cunningham wrote:you know hes the kind of people who drive people away from the forum
I'm sorry you feel that way. I don't think it's fair of you to not demonstrate any effort and expect us to do the work. I'm happy to explain it furthur if you need.

What have you tried so far?
User avatar
Stryks
Forum Regular
Posts: 746
Joined: Wed Jan 14, 2004 5:06 pm

Re: Password

Post by Stryks »

Actually, He's the kind of person who makes this site so worthwhile.

He *could* just give you the code ... you'd go away happy for five minutes, then want to get it to work slightly differently, and then realize that you had no understanding of how the code actually worked. Then you'd come back, and someone would fix it. All the while, you'd be going nowhere with PHP.

Seriously, take a look at the manual pages ... have a read and then make up a few test files and get a feel for how things work. See if you can tell how the commands would work together. It'll be sooooo worth your while.

And if you try and fail, come back and post your code. There are hundreds of people here, JCart included I'm sure, who would bend over backwards to help you understand where your code was going wrong.

We're here to help.
User avatar
Jasheppard
Forum Newbie
Posts: 24
Joined: Tue Jun 17, 2008 11:44 pm

Re: Password

Post by Jasheppard »

its easy. but there is no point in learning or using php if you don't know how to create forums and read data out of a file!

look in google... always help for me :D but why go that far? i have seen examples in other topics on this forum.
User avatar
Jasheppard
Forum Newbie
Posts: 24
Joined: Tue Jun 17, 2008 11:44 pm

Re: Password

Post by Jasheppard »

There are many ways on how to make a password/login system.

1. Databases...
2. Text files...
3. could even use session which is quite pointless.

But i would go for text files, for which i use on my website.
As Jcart said...
use file() to load each line into an array, foreach() to traverse the array, and explode() to seperate the elements on the colon.
Simple, I would post the code but i am afraid its a bit too big.
Last edited by Jasheppard on Wed Jun 25, 2008 2:07 am, edited 1 time in total.
User avatar
Stryks
Forum Regular
Posts: 746
Joined: Wed Jan 14, 2004 5:06 pm

Re: Password

Post by Stryks »

How did you go with those examples you found?

How did they not do what you want? Did you test them?
Post Reply