Skip to content
pakainfo

Pakainfo

Web Development & Good Online education

  • Home
  • Blog
  • Categories
  • Tools
  • Full Form
  • Guest Post
  • Advertise
  • About
  • Contact Us

How to create a Login page with PHP and MySQL

June 19, 2018 Pakainfo Programming, Mysql, Mysqli, php Leave a comment

How to create a Login page with PHP and MySQL

Contents

  • How to create a Login page with PHP and MySQL
    • PHP Login Page Example Steps
    • Step 1 Database
    • Step 2 Config.php
    • Step 3 Login.php
    • Step 4 lock.php
    • Step 5 welcome.php
    • Related posts

In this Post We Will Explain About is How to create a Login page with PHP and MySQL With Example and Demo.Welcome on Pakainfo.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to Creating a User Login System with PHP and MySQL Example

In this post we will show you Best way to implement How to create a Login page with PHP and MySQL, hear for How to Create a Login Page in PHPwith Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

Free Live Chat for Any Issue

PHP Login Page Example Steps

Hello, Are you looking for simple Auth module PHP login script, in this post I want to Learn how to create a simple scripts PHP login with welcome page (Dashboard) using MySQL database.here This will explain you step by step creating user tables and managements, posting form some values and storing data and destroying data the session values. This login post has been some updated with mysqli.

Also Read This πŸ‘‰   Get Gravatar Image Using PHP Example

Step 1 : Database

MySQL simple userMst table columns Like as a id, clientName, passcode.

CREATE TABLE userMst
(
id INT PRIMARY KEY AUTO_INCREMENT,
clientName VARCHAR(30) UNIQUE,
passcode VARCHAR(30)
);

Step 2 : Config.php

Simple Database configuration file.

<?php
define('DB_SERVER', 'YOUR_localhost');
define('DB_USERNAME', 'YOUR_username');
define('DB_PASSWORD', 'YOUR_password');
define('DB_DATABASE', 'YOUR_database_name');
$db = mysqli_connect(DB_SERVER,DB_USERNAME,DB_PASSWORD,DB_DATABASE);
?>

Step 3 : Login.php

Simple steps to Contains PHP and HTML Source code.

<?php
include("config.php");
session_start();
if($_SERVER["REQUEST_METHOD"] == "POST")
{
// clientName and password sent from Form
$my_clientName=mysqli_real_escape_string($db,$_POST['clientName']); 
$mypassword=mysqli_real_escape_string($db,$_POST['password']); 

$sql="SELECT id FROM userMst WHERE clientName='$my_clientName' and passcode='$mypassword'";
$data_result=mysqli_query($db,$sql);
$row=mysqli_fetch_array($data_result,MYSQLI_ASSOC);
$active=$row['active'];
$count=mysqli_num_rows($data_result);


// If data_result matched $my_clientName and $mypassword, table row must be 1 row
if($count==1)
{
session_register("my_clientName");
$_SESSION['login_user']=$my_clientName;

header("location: welcome.php");
}
else 
{
$error="Your USER Login Name or Password is wrong";
}
}
?>
<form action="" method="post">
<label>Eneter Your  UserName :</label>
<input type="text" name="clientName"/><br />
<label>Eneter Your Password :</label>
<input type="password" name="password"/><br/>
<input type="submit" value=" Submit "/><br />
</form>

Step 4 : lock.php

Simple Session verification. If no any create session value page redirect to simple main login.php

Also Read This πŸ‘‰   select query in wordpress - how to run Select Query in wordpress?

<?php
include('config.php');
session_start();
$session_check=$_SESSION['login_user'];

$ses_sql=mysqli_query($db,"select clientName from userMst where clientName='$session_check' ");

$data_row=mysqli_fetch_array($ses_sql,MYSQLI_ASSOC);
$user_login_ses=$data_row['clientName'];
if(!isset($user_login_ses))
{
	header("Location: login.php");
}
?>

Step 5 : welcome.php

<?php
include('lock.php');
?>
<body>
<h1>Pakainfo.com Welcome <?php echo $user_login_ses; ?></h1>
</body>

logout.php

and then Last step to SignOut all the session Destroy the session value.

<?php
session_start();
if(session_destroy())
{
	header("Location: login.php");
}
?>

Example

I hope you have Got What is PHP Login Page Example with Demo And how it works.I would Like to have FeadBack From My Blog(Pakainfo.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(Pakainfo.com) Are Most Always Welcome.

Pakainfo
Pakainfo

I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I’m a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.

Also Read This πŸ‘‰   Laravel 6 Define Global Constants Config PHP file

Related posts:

  1. Create a Registration and Login System with PHP and MySQL
  2. jQuery Ajax Secure Login Registration System in PHP and MySQL
  3. how to make a login page in html with database?
  4. How To Create Image Hover Overlay Effects?
  5. Secure Login System with PHP and MySQLi – login page in php
  6. html code for login page with username and password validation
  7. PHP login logout script with session Example
  8. How To Create Social Media icons footer using bootstrap?
  9. Multiple image slider in html source code
complete login system php mysqllogin page in php with database and validationlogin page in php with database source codephp login form w3schoolsphp login form with mysql database examplephp login sessionregistration and login form in php and mysqlsimple login form in php

Post navigation

Previous Post:Laravel 5.4 Paypal integration – Paypal Payment Gateway
Next Post:Ajax PHP MySQL Creating Autocomplete Search Suggestion

Search

Write For Us

We’re accepting well-written informative guest posts and this is a great opportunity to collaborate.
Submit a guest post to [email protected]
Contact Us

Freelance web developer

Do you want to build a modern, lightweight, responsive website quickly?
Need a Website Or Web Application Contact : [email protected]
Note: Paid Service
Contact Me

Categories

3movierulz (56) Ajax (464) AngularJS (377) ASP.NET (61) Bollywood (100) Codeigniter (175) CSS (98) Earn Money (61) Education (56) Entertainment (121) fullform (82) Google Adsense (62) Highcharts (77) Hollywood (101) JavaScript (1356) Jobs (40) jQuery (1422) Laravel (1087) LifeStyle (51) movierulz4 (55) Mysql (1029) Mysqli (890) Node.js (39) php (2117) Programming (2330) Python (96) ReactJS (37) Software (134) Software (83) Stories (94) tamilrockers (96) Tamilrockers kannada (56) Tamilrockers telugu (55) Tech (132) Technology (2377) Tips and Tricks (113) Tools (168) Top10 (388) Trading (69) Trending (63) VueJs (250) Web Technology (93) webtools (173) wordpress (166) World (209)

Advertise With Us

Increase visibility and sales with advertising. Let us promote you online.
Click Here

A To Z Full Forms

Access a complete full forms list with the meaning, definition, and example of the acronym or abbreviation.
Click Here

  • Home
  • About Us
  • Terms And Conditions
  • Write For Us
  • Advertise
  • Contact Us
  • Youtube Tag Extractor
  • Guest Posting Sites
  • Increase Domain Authority
  • Social Media Marketing
  • Freelance web developer
  • Tools
Pakainfo 9-OLD, Ganesh Sco, Kothariya Ring Road, Chokadi, Rajkot - 360002 India
E-mail : [email protected]
Pakainfo

Β© 2022 Pakainfo. All rights reserved.

Top
Subscribe On YouTube : Download Source Code
We accept paid guest Posting on our Site : Guest Post Chat with Us On Skype YouTube Tag Extractor