View Full Version : [PHP]Simple Flat File Login Form

07-18-2005, 18:23 PM
[PHP]Simple Flat File Login Form

In this tutorial, I will show you have to creat a simple flatfile PHP login system.

This is our code, I will break it down at the end:

<form action="./login.php" method="post">
<input type="text" name="uname">
<input type="password" name="pwd">
<input type="submit" value="Login!">

if ($_POST[pwd] !== "test" || $_POST[uname] !== "test") {
echo "Sorry, try again!";
} else {
echo "Welcome $_POST[uname]!";

To break it down, the HTML is pretty simple. It is a form that will verify on it's self.

The PHP between the <? ?> tags verifys than information. Right now we have the username & password set to 'test'. You can set these to anything you wish. The != says if the username & password are NOT equal to test, do this. I have it set to echo Sorry, try again. If it is equal, it will go the the } else { and display anything under that. I hope this tutorial helped some. I will soon do one with MySQL and cookies.

07-19-2005, 07:02 AM
But its plaintext format