Đăng nhập admin php

Tutorials Algorithms Analysis of Algorithms Data Structures Languages Interview Corner GATE ISRO CS UGC NET CS CS Subjects Web Technologies Student Jobs
*

*

*

*

Follow the steps to create an admin login page using PHP:Here, we have created a login page of admin, connected with the database, or whose information lớn log in lớn the page is already stored in our database.

Bạn đang xem: Đăng nhập admin php

1. Create Database: Create a database using XAMPPhường, the database is named “loginpage” here. You can give sầu any name khổng lồ your database.

*

2. Create Table: Create a table named “adminlogin”, inside “loginpage” database.

*

3. Create Table Structure: The table “adminlogin” should contain three fields.


id – primary key – tự động incrementadminname – varchar(100)password – varchar(100)

The datatype for adminname & password is varchar. The size can be altered as per the requirement. However, 100 is sufficient, and the datatype for “id” is int và it is a primary key.A primary key also called a primary từ khoá is a key in a relational database that is unique for each record. It is a unique identifier, such as a driver’s license number, telephone number (including area code), or vehicle identification number (VIN).

*

The structure of the table will look like this

*

4. Insert admin login information: Here, the information of 2 admin are inserted. You can add as many as you want.

*

Or you can write an Squốc lộ query khổng lồ insert the values.

Xem thêm: Phần Mềm Oxy - Hướng Dẫn Tải Phần Mềm Mixer Djg K999

*


After inserting the values, the table will look like this.

*

5. Create a folder that includes the following files: The folder should be in “D:xampphtdocs” (or where your XAMPP is installed). On Linux “/opt/lampp/htdocs”.

Filename: index.php

html


filter_none

edit close


play_arrow


liên kết brightness_4 code
html lang="en">
head>
meta charset="UTF-8">
link rel="stylesheet" href=
"https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
meta name="viewport" content="width=device-width, initial-scale=1.0">
meta http-equiv="X-UA-Compatible" content="ie=edge">
link rel="stylesheet" href="login.css">
title>Login Pagetitle>
head>
body>
size action="validate.php" method="post">
div class="login-box">
h1>Loginh1>
div class="textbox">
i class="fa fa-user" aria-hidden="true">i>
đầu vào type="text" placeholder="Adminname"
name="adminname" value="">
div>
div class="textbox">
i class="fa fa-lock" aria-hidden="true">i>
input đầu vào type="password" placeholder="Password"
name="password" value="">
div>
input class="button" type="submit"
name="login" value="Sign In">
div>
form>
body>
chevron_right


filter_none


Filename: connection.php

php


filter_none

edit close


play_arrow


liên kết brightness_4 code
$conn = "";
try
$servername = "localhost:3306";
$dbname = "loginPage";
$username = "root";
$password = "";
$conn = new PDO(
"mysql:host=$servername; dbname=loginPage",
$username, $password
);
$conn->setAttribute(PDO::ATTR_ERRMODE,
PDO::ERRMODE_EXCEPTION);

catch(PDOException $e)
emang lại "Connection failed: " . $e->getMessage();

?>
chevron_right


filter_none


Filename: login.css

css


filter_none

edit close


play_arrow


links brightness_4 code
body
margin: 0;
padding: 0;
font-family: sans-serif;
background: url() no-repeat;
background-size: cover;

.login-box
width: 280px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
color: #191970;

.login-box h1
float: left;
font-size: 40px;
border-bottom: 4px solid #191970;
margin-bottom: 50px;
padding: 13px;

.textbox
width: 100%;
overflow: hidden;
font-size: 20px;
padding: 8px 0;
margin: 8px 0;
border-bottom: 1px solid #191970;

.fa
width: px;
float: left;
text-align: center;

.textbox đầu vào
border: none;
outline: none;
background: none;
font-size: 18px;
float: left;
margin: 0 10px;

.button
width: 100%;
padding: 8px;
color: #ffffff;
background: none #191970;
border: none;
border-radius: 6px;
font-size: 18px;
cursor: pointer;
margin: 12px 0;

chevron_right


filter_none


Filename: validate.php

php


filter_none

edit close


play_arrow


links brightness_4 code
include_once("connection.php");
function test_input($data)
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;

if ($_SERVER<"REQUEST_METHOD">== "POST")
$adminname = test_input($_POST<"adminname">);
$password = test_input($_POST<"password">);
$stmt = $conn->prepare("SELECT * FROM adminlogin");
$stmt->execute();
$users = $stmt->fetchAll();
foreach($users as $user)
if(($user<"adminname"> == $adminname) &&
($user<"password"> == $password))
header("Location: adminpage.php");

else
emang đến "";
die();



?>
chevron_right


filter_none


Filename: adminpage.php Add anything that you want to lớn display lớn the admin page.

html


filter_none

edit close


play_arrow


link brightness_4 code
h2>Hello Adminh2>
chevron_right


filter_none


6. After completing all the above sầu steps, now follow the steps:

Run XAMPPStart Apabít và MySQL serverType http://localhost/loginPage/ in your browser.

This login page will appear.

*

If you enter the correct credentials i.e. admin name & password, then you will be logged-in khổng lồ the “admin.php” page.

*

else, you get an error pop-up alert.

*

*


My Personal Notes arrow_drop_up
Save sầu
favorite_border Like
first_page Previous
How to lớn display logged in user information in PHPhường ?
Next last_page
HTML | Responsive sầu Modal Login Form
Recommended Articles
Page :
How khổng lồ pass size variables from one page to lớn other page in PHPhường ?
22, Nov 19
How to display search result of another page on same page using ajax in JSP?
29, Aug 19
How khổng lồ show Page Loading div until the page has finished loading?
27, Sep 19
How to redirect a page lớn another page in HTML ?
11, Oct 19
How to add a Login Form to an Image using HTML and CSS ?
19, Dec 19
Login size using Node.js and MongoDB
04, Jun 20
Login and Registration Project Using Flask và MySQL
19, Aug 20
How to lớn kiến thiết login dialog using jQuery EasyUI Smartphone ?
13, Dec 20
Design a transparent login/Sign Up webpage using HTML and CSS
09, Dec 20
HTML | Responsive Modal Login Form
21, Nov 17
Automated Login For Captive sầu Portals in Linux
12, Feb 20
How to implement Facebook login in your Web phầm mềm with Firebase ?
05, Jun 20
How to lớn implement Google Login in your Web ứng dụng with Firebase ?
11, Jun 20
How lớn use Selenium Web Driver và JavaScript lớn Login any trang web ?
30, Jun 20
HTML Neumorphism Login Form
07, Aug 20
How to lớn create fade-in effect on page load using CSS ?
21, May 19
How lớn create content area scrollable instead of the page using CSS ?
14, Dec 20
How lớn create footer to lớn stay at the bottom of a Web page?
22, May 19
Service Worker | How to create custom offline page ?
29, Aug 19
How lớn Create a Facebook Phishing Page ?
14, Feb 20
Refresh a page using PHP
05, Atruyền thông quảng cáo 19
How khổng lồ get the source code of a web page using PHP.. ?
08, Feb 21
PHPhường Program lớn count Page Views
15, Jan 18
How to add API function to lớn a simple PHP Page ?
28, Jan 20
Article Contributed By :
*

nehaahlawat
nehaahlawat
Vote for difficulty
Current difficulty : Hard
Easy Normal Medium Hard Expert
Improved By :
Report Issue
What’s New
Data Structures và Algorithms – Self Paced Course
View Details
Ad-Free Experience – obatambeienwasirherbal.com Premium
View Details
Most popular in CSS
Most visited in HTML

Writing code in comment? Please use ide.obatambeienwasirherbal.com, generate links & nói qua the link here.


Load Comments
5th Floor, A-118, Sector-136, Noidomain authority, Uttar Pradesh - 201305
feedback
obatambeienwasirherbal.com
Company Learn Practice Contribute
obatambeienwasirherbal.com , Some rights reserved
We use cookies to ensure you have sầu the best browsing experience on our trang web. By using our site, you acknowledge that you have sầu read and understood our Cookie Policy và Privacy Policy Got It !