YouFail
01-08-2006, 12:36 PM
This is my first tutorial so I hope I explain it in enough detail.
<form name="login" method="post" action="protected.php">
Username:
<input name="formuser" type="text" id="formuser">
<br>
Password:
<input name="formpass" type="password" id="formpass">
<br>
<input type="submit" name="Submit" value="Submit">
<input type="reset" name="Reset" value="Reset">
</form>
Thats the basic Form that has a submit button etc.
Next make a page called protected.php and enter this code:
<?php
$user = "USERNAME HERE";
$password = "PASSWORD HERE";
$formuser = $_POST["formuser"];
$formpass = $_POST["formpass"];
if(($formuser == $user) && ($formpass == $password)){
//Protected Content here
}
else {
echo("Login Incorrect, Please click back and try again");
}
?>
<?php - Starts the php
$user = "USERNAME HERE"; - That just says that if the username entered is that its true
$password = "PASSWORD HERE"; - That just says that if the password entered is that its true
$formpass = $_POST["formpass"];
if(($formuser == $user) && ($formpass == $password)){
//Protected Content here
}
else {
echo("Login Incorrect, Please click back and try again");
}
?>
Unless you know what your doing dont change anything there except the bit in bold
And voila you have your simple login!
<form name="login" method="post" action="protected.php">
Username:
<input name="formuser" type="text" id="formuser">
<br>
Password:
<input name="formpass" type="password" id="formpass">
<br>
<input type="submit" name="Submit" value="Submit">
<input type="reset" name="Reset" value="Reset">
</form>
Thats the basic Form that has a submit button etc.
Next make a page called protected.php and enter this code:
<?php
$user = "USERNAME HERE";
$password = "PASSWORD HERE";
$formuser = $_POST["formuser"];
$formpass = $_POST["formpass"];
if(($formuser == $user) && ($formpass == $password)){
//Protected Content here
}
else {
echo("Login Incorrect, Please click back and try again");
}
?>
<?php - Starts the php
$user = "USERNAME HERE"; - That just says that if the username entered is that its true
$password = "PASSWORD HERE"; - That just says that if the password entered is that its true
$formpass = $_POST["formpass"];
if(($formuser == $user) && ($formpass == $password)){
//Protected Content here
}
else {
echo("Login Incorrect, Please click back and try again");
}
?>
Unless you know what your doing dont change anything there except the bit in bold
And voila you have your simple login!