[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:
Login.php:
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.
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:
Login.php:
HTML Code:
<html> <head> <title>Login</title> </head> <body> <form action="./login.php" method="post"> <input type="text" name="uname"> <input type="password" name="pwd"> <input type="submit" value="Login!"> </form> </body> </html> <? 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.
Comment