Login form with HTML/CSS, PHP and MySQL
In this tutorial, we show you how to create a login form using the HTML, PHP, and MySQL extension. This authentication form is used when a user needs to submit a form to authorize them to access their account, for example.Four steps to create a login form:
1- Create an HTML file containing the structure of the form;
2- Create a CSS file to define the style;
3- Create a PHP login file that will check the form fields if they match the values of the table in the database;
4- Create a PHP file of the main page and the logout.
Step 1:
First, we will create an HTML page login.php.login.php:
< head>
< meta charset="utf-8">
< link rel="stylesheet" href="style.css" media="screen" type="text/css" />
< body>
< div id="container">
< form action="verification.php" method="POST">
< h1> Login
< label> < b> Username
< input type="text" placeholder="Enter username" name="username" required>
< label> < b> Password
< input type="password" placeholder="Enter password" name="password" required>
< input type="submit" id='submit' value='LOGIN' >
php
if(isset($_GET['error'])){
$err = $_GET['error'];
if($err==1 || $err==2)
echo "< p style='color:red'> Incorrect user or password";
}
?>