logo

  • Hỏi Đáp
  • Kiến Thức
  • Sức Khỏe
  • Tử Vi
  • Công Nghệ
No Result
View All Result
logo
No Result
View All Result
Trang chủ php tutorial: extract & compact methods

Php Tutorial: Extract & Compact Methods

by Admin _ May 04, 2022

Login page allows the registered user khổng lồ access the website và manage its account by entering its username và password.Bạn đã xem: Create a registration and login system with php & mysql

User SESSION is been created on a successful login attempt.

Bạn đang xem: Php tutorial: extract & compact methods

This helps to detect the user is actually logged in or not when going lớn other website pages and it also helps lớn display nội dung according to lớn the user.

In this tutorial, I show how you can create a Login page with PHP & MySQL.


*

Contents

1. Table structure

I am using users table in the tutorial example.

CREATE TABLE `users` ( `id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT, `username` varchar(80) NOT NULL, `name` varchar(80) NOT NULL, `password` varchar(80) NOT NULL) ENGINE=InnoDB mặc định CHARSET=latin1;

2. Configuration

Create a new config.php file for database configuration.

Completed Code

3. HTML

Completed Code

4. CSS

/* Container */.container width:40%; margin:0 auto;/* Login */#div_login border: 1px solid gray; border-radius: 3px; width: 470px; height: 270px; box-shadow: 0px 2px 2px 0px gray; margin: 0 auto;#div_login h1 margin-top: 0px; font-weight: normal; padding: 10px; background-color: cornflowerblue; color: white; font-family: sans-serif;#div_login div clear: both; margin-top: 10px; padding: 5px;#div_login .textbox width: 96%; padding: 7px;#div_login input padding: 7px; width: 100px; background-color: lightseagreen; border: 0px; color: white;

5. PHP

On size submit check the username and password entered or not. If entered then execute a SELECT query khổng lồ count records on the basis of username & password.

Xem thêm: Cách Lên Bảng Ngọc Phép Liên Quân, Mùa 19 Mạnh Nhất 2021

If the query returns greater than 0 then initialize $_SESSION = $uname & redirect to lớn home.php.

If it returns 0 then display the "Invalid username và password message".

Complete Code

0) $_SESSION = $uname; header("Location: home.php"); else echo "Invalid username & password"; }}

Homepage

Create new home.php file.

First, check whether the user is logged or not by checking the $_SESSION variable. If it not mix then redirect the user to lớn index.php for login.

Created a logout button that destroy the $_SESSION variable and redirect to index.php web page on click.

Share Tweet Linkedin Pinterest
Previous Post

Url parameter php _get

Next Post

Foreach sleep php

CÙNG CHUYÊN MỤC

form register php

Form register php

09/04/2021
fantastic blog (cms) in php with source code

Fantastic blog (cms) in php with source code

28/04/2021
validate form php javascript

Validate form php javascript

28/04/2021
http diendanlequydon com viewtopic php style 6

Http diendanlequydon com viewtopic php style 6

28/04/2021
cách làm website bằng php

Cách làm website bằng php

25/05/2022
hướng dẫn cài đặt và sử dụng composer trên ubuntu 20

Hướng dẫn cài đặt và sử dụng composer trên ubuntu 20

25/05/2022
so sánh giờ trong php

So sánh giờ trong php

25/05/2022
hướng dẫn sử dụng chức năng

Hướng dẫn sử dụng chức năng "config php timezone"

24/05/2022

Newsletter

The most important automotive news and events of the day

We won't spam you. Pinky swear.

Chuyên Mục

  • Hỏi Đáp
  • Kiến Thức
  • Sức Khỏe
  • Tử Vi
  • Công Nghệ

News Post

  • Free dvd player

About

Chúng tôi tạo ra trang web nhằm mục đích mang lại kiến thức bổ ích cho cộng đồng, các bài viết được sưu tầm từ nhiều nguồn trên internet giúp mang lại kiến thức khách quan dành cho bạn

©2022 darkedeneurope.com - Website WordPress vì mục đích cộng đồng

Liên Hệ - Giới Thiệu - Nội Quy - Bảo Mật

No Result
View All Result
  • Trang chủ
  • Chuyên mục
    • Hỏi Đáp
    • Kiến Thức
    • Sức Khỏe
    • Tử Vi
    • Công Nghệ
  • Lưu trữ
  • Liên hệ

© 2022 darkedeneurope.com - Website WordPress vì mục đích cộng đồng.