Login form in php

Hello guyz, In this simple but very important article i am going to give some tips to you how to create a login form in PHP using Dreamweaver CC and MySQL Database. Creating a login form is very simple tasks but it tells you how to connect to the database, even how to create database in you localhost and how to create table in the database and many more things.

Before this you should know how to define site and testing server in Dreamweaver cc because PHP is Server site scripting language thats why it does not executed by the browser. So for this reason you have to install the server application like Wamp server, xamp server for windows and PAMP Server for mac. Before starting this little project first read this article:

Now follow the following steps:

1. After download and installing open it and then open your localhost, for this open up your any browsing software and type localhost or in the address bar. Then new page will appear then scroll down and find phpmyadmin and click on that. Then you will be able to see the login page. Login in by entering username and password (Default username is root and password is empty). And then click on new and create one database having any name you want and the click ok, then create table having any number of field you want but i am using four field in this case and click on go. After that, you need to insert the field name like: username, password. and then select the length as well as data type as your requirement and then click on save. You can watch the video for this designing part, you may understand better in video.

2. Write the following code:

<!doctype html>
$servername = "localhost";
//create connection
$conn=new MySQLi($servername,$username,$password,$dbname);

//check the connection
die("connection failed".$conn->connect_error);
$pass =$_POST['pass'];
$sql ="select * from login where username = '".$user."' and password='".$pass."' LIMIT 1";
$result = $conn->query($sql);
echo("you have successfully loggined");
echo("goto previous page");
<meta charset="utf-8">
<title>login form</title>
<style type="text/css">
body {
background-color: #F1E2E2;

<form method="post" action="login.php">
username:<input type="text" name="user"><br><br>
password:<input type="text" name="pass"><br><br>
<input type="submit" value="login">

3. save the file in localhost and run.

For more details:


Please enter your comment!
Please enter your name here