,
Share this with your friends 
 

Simple Dynamic Login Pannel

6 ratings Views 266 
Author: Abhinav_880647d3 (Abhinav Sharma)  View Profile |  View other solutions by this author

Question / Problem


Problem:- Login with username and password from database with the help of PHP ,Mysqli

Solution

For solving this firstly we have to create database and table...

Step:1 Create Database -
create database login_details // run on phpmyadmin or direct sql console

Step:2 Create Table-
CREATE TABLE IF NOT EXISTS `details` (
`sno` int(11) NOT NULL AUTO_INCREMENT,
`username` text NOT NULL,
`password` text NOT NULL,
PRIMARY KEY (`sno`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1


Step:3 Insert dummy Values in this table like for username we assume="admin" and for password we assume="admin" .

Step:4 Get values from PHP form by POST Method
Step:5 <?php
session_start(); // sessiom start
$con=mysqli_connect("localhost","root","","login_details"); // connect from server
if($_SERVER['REQUEST_METHOD']=="POST") // check for post method
{
$username=$_POST['username']; // make var
$password=$_POST['password']; // make var

$q="select * from details where username='$username' and password='$password'";// query for check username and password
$res=mysqli_query($con,$q);// run query
if(mysqli_num_rows($res)==1) // check whether return number of rows will be 1 or not
{
echo "<script>alert('Login Done Successfully..!')</script>";
}
else
{
echo "<script>alert('Invalid Username or Password')</script>";

}
}

?>

Step 6 :-Simple Login programme done successfully..!

Applies to

PHP

Rank It

Login to rank it

Report


Advertisement