Login with txt to store variables...

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
molandim
Forum Newbie
Posts: 19
Joined: Thu Feb 20, 2003 11:33 am
Location: Brazil
Contact:

Login with txt to store variables...

Post by molandim »

Hi, I'am a stupid in PHP.

I only know actionscript and html .... I know that I can do a script for login that read the variables "name" and "password" in a txt file..
Now...How do that ??

How pull this informations from the txt file ???

Help me !!! :roll:
User avatar
uberpolak
Forum Contributor
Posts: 261
Joined: Thu Jan 02, 2003 10:37 am
Location: Next to the bar

Post by uberpolak »

Do you mean check the values entered in the form against those in a text file? If that's what you're trying to do you could do this (not very secure but it works):

Contents of text file:

Code: Select all

<?php

$name = "whatever you want the acceptable name to be";
$password = "whatever you want the password to be";

?>
Then the script that processes the form could look like this:

Code: Select all

<?php

include("nameofyourtextfile.txt");
if ($_POST['name'] == $name && $_POST['password'] == $password)
{
 header("Location: wherever you want to send them if they get it right");
}
else
{
 header("Location: wherever they just came from");
}
?>
Like I said, this is not very secure, there are much better ways of doing this. If you want to use user authentication you should probably look into a database, but this will do it from a text file.
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post by hob_goblin »

You shouldn't use the .txt extension, you should use the .php extension, so the password can't be seen by anybody.
Post Reply