Hey there,

Today’s post is very simple. I’d like you guys to learn on how to create a really simple form. And it may looks difficult, but you should really try it first and you’ll understand later how simple this thing is. So here’s the code.

 

<!DOCTYPE html>
<body>

<form action=”login.php” method=”POST”>

<input type=”text” name=”user”>
<input type=”pass” name=”pass”>
<input type=”submit” name=”submit”>
</form>

</body>
</html>

<?php

session_start();

$user = $_POST[‘user’];

$pass = $_POST[‘pass’];

if(isset($_POST[‘submit’]))
{
if($user==”me” AND $pass==123)
{
header(“Location:login2.php”);

}
else
{
echo “Wrong Username / Password.”;
}
}

?>

 

Right now, login.php is the file that has this code.. and if the login is correct which is set to have the username of “me” and password 123, it will be redirected to login2.php. So maybe my next post would be more interesting with the use of session so that you can login and logout.

Any inquiries, mail me at imdad@zeroprogrammer.com