How to make admin page with database


#0: Strategy Used behind the Login System:

Here we shall use 5 files for making the whole system.file structure
  • config.php: The main file for holding the information related to the admin MySQL table. We shall discuss in brief how to create the table. For information do check the MySQL posts.
  • admin.php: For administrative functions. It will redirect to login.php if not authorized already;
  • login.php: A webpage for displaying form of login. It will submit the form to check_login.phpwhere it will be processed further;
  • check_login.php: A PHP script to check the login details from the MySQL Table. If successfully matched, then it will register the Session, else will redirect back to the login.php file with error message;
  • logout.php: It will delete the session, and will redirect back to login.php file with success message;

#1: Setting up the MySQL Table:

We shall use a MySQL table like this for storing administrator information:
iduser_nameuser_pass
1adminadmin
2swashataswashata
Basically we shall encrypt the password inside the table. Just for the demonstration I have showed the passwords above…
Now create a Database and inside it create a table login_admin with the following MySQL query command:
?
1
2
3
4
5
6
7
CREATE TABLE login_admin
(
id INT NOT NULL AUTO_INCREMENT,
user_name VARCHAR(100),
user_pass VARCHAR(200),
PRIMARY KEY (id)
)
Now insert the two user information inside the table with the following command:

INSERT INTO login_admin (user_name, user_pass)
VALUES
(
‘swashata’, SHA(‘swashata’)
)
INSERT INTO login_admin (user_name, user_pass)
VALUES
(
‘admin’, SHA(‘admin’)
)

Now your MySQL table is ready for use!

#2: Setting up the config.php file:

As mentioned before, it just contains all the necessary MySQL Database connection information. Here is the code for this file:

<?php
/**********************************************************************
 *Contains all the basic Configuration
 *dbHost = Host of your MySQL DataBase Server... Usually it is localhost
 *dbUser = Username of your DataBase
 *dbPass = Password of your DataBase
 *dbName = Name of your DataBase
 **********************************************************************/
$dbHost = 'localhost';
$dbUser = 'Data Base User Name';
$dbPass = 'Data Base Password';
$dbName = 'Data Base Name';
$dbC = mysqli_connect($dbHost, $dbUser, $dbPass, $dbName)
        or die('Error Connecting to MySQL DataBase');
?>
Just save this file with the above codes.



Related Posts:

  • How to Bypass Blocked Online Games at School or University How to Bypass Blocked Online Games at School or University                                               &n… Read More
  • Fulham Vs Man Utd (last night) Fulham1 Kacaniklic 65′ Man Utd3 Antonio Valencia 9′van Persie 20′Rooney 22′ FT 90 +4 HT 0-3 2 November 2013Last updated at 17:12 GMT 429 Share Facebook Twitter pr… Read More
  • Cara Kuruskan Perut BuncitDibawah ini ada beberapa cara untuk menurunkan berat badan yang berlebihan dan kempiskan perut. 1. Air limau nipis yang anda minum boleh menurunkan berat badan anda. Caranya: Sediakan dua biji limau nipis atau limau kastu… Read More
  • Cara Membuat Blog Terbaru 2013 Cara Membuat Blog Terbaru 2013 Cara membuat blog terbaru 2013, walau aku terhitung blogger baru alias newbie tapi ku coba membuat postingan cara membuat blog yang diharapkan bisa menjadi referensi buatku sendiri keti… Read More
  • How to Start a Blog on Blogger How to Start a Blog on Blogger Blogger is an online service owned by Google that publishes single or multi-user blogs created entirely by the user. The service has quickly become the preferred choice of many novice blogg… Read More

0 ulasan: