• Home
  • Donate
  • Tentang kita :
  • Menggunakan Jasa itx
itx si tukang kritix
bukan untuk membenci, bukan untuk mencaci, tapi untuk memahami
  • PHP
  • WordPress
    • WordPress Plugins
  • Bahasa Inggris
  • Indonesia
  • Jawa
  • jQuery
  • Selingan
  • Lowongan Penulis
  • my twitter
  • my facebook
  • itx si tukang kritix
2

Multi-User Login with PHP and Mysql

November 20, 2010
by littleflow3r

Case Study : Creating a Multi-User Login System with PHP and Mysql.

Requirements : Webserver Packages (AppServ, XAMPP, EasyPHP, etc)

Step 1 : Preparing the Database

  1. Prepare a database with the name db_multiuser.
  2. Create a table named tb_user, create the fields – fields like the following picture,

    Struktur Tabel

  3. Insert some sample data to tb_user.
    INSERT INTO `db_multiuser`.`tb_user` (`id`, `username`, `password`, `tipe`) VALUES (NULL, 'ani', 'ani','admin'), (NULL, 'budi', 'budi', 'operator');

Step 2 :Create the configuration file

  1. Type the following script,
    <?php
    $host = "localhost";
    $user = "root"; //adjust to your mysql user

    $pass = ""; //i use no password in my mysql
    $dbName = "db_multiuser";
    mysql_connect($host, $user, $pass);
    mysql_select_db($dbName)
    or die ("Connect Failed : ".mysql_error());
    ?>
  2. Save with the name connect.php
  3. Explanation: connect.php is a configuration file that would link the login system that we created with mysql database.

Step 3 :Create the login form

  1. Type the following script,
    <center>
    <h2> <b> Login Page </b> <h2><form method="post" action="proses.php"><table border="0" align="center" cellpadding="5" cellspacing="8"><tr bgcolor="orange">
    <td> UserName! </td>
    <td> <input name="username" type="text"> </td>
    </tr>
    <tr bgcolor="orange">
    <td> Password ! </td>
    <td> <input name="password" type="password"> </td>
    </tr>
    <tr>
    <td> &nbsp; </td>
    <td> <input name="submit" type="submit" value="login"> </td>
    </tr>
    </table>
    </form>
    </center>
  2. Save with the name formlogin.php
  3. This script will display a login form for username and password fields. Consider the action="proses.php". This shows that the entries from the username and password will be processed (given the action) by proses.php file. This file will be created in the next step.

Step 4 :Create the processing file for login

  1. Type the following script,
    <?php
    session_start(); //startsession
    include "connect.php";//get the username and password from the form
    $username = $_POST['username'];
    $password = $_POST['password'];
    //query for retrieve the user data from database according to username in the form
    $q = "SELECT * FROM tb_user WHERE username = '$username' ";
    $result = mysql_query($q);
    $data = mysql_fetch_array($result);
    //checking the password
    if ($password == $data['password']) {
    //save usertype & username in the session
    $_SESSION['tipe'] = $data['tipe'];
    $_SESSION['username'] = $data['username'];
    include "menu.php";
    }
    //If password doesnt match
    else {
    $warning = "Wrong Username / Password";
    echo $warning;
    }
    ?>
  2. Save with the name proses.php

Step 5 : Make a display special for user

  1. Type the following script,
    <?php
    session_start();
    include "connect.php";
    echo "<center>";
    echo "<h3> Menu </h3>";
    if ($_SESSION['tipe'] == "admin") {
    echo " Anda Login sebagai Admin";
    }
    else if ($_SESSION['tipe'] == "user") {
    echo " Anda Login sebagai User";
    }
    ?>
  2. Save with the name menu.php
  3. Explanation: This script will display the information in accordance with the users who are logged.

Step 6 : Running the Login System

  1. Go to http://localhost/
  2. Select file formlogin.php to start running the application. You will see a display like the following,

    Login Page

  3. Set the username = ani; password = ani
  4. System will display the description as follows,

    Admin Login

  5. If you log in as an operator (username: budi; password: budi), it will display information as shown below,

    Operator Login

NB. Save all the php file from step 2 – step 5 into the SAME ONE folder.

Okay then, happy coding (:
Hal yang juga menarik:

Hak Cipta

Semua skrip dan teknik dalam artikel di itx.web.id boleh digunakan sebagaimana kehendakmu tanpa perlu mencantumkan sumber. Kamu tidak boleh mengkopi seluruh artikel, dalam Bahasa Indonesia ataupun diterjemahkan ke dalam bahasa lain.


Related Articles:

  • “Bermain” dengan Code Igniter FULL : Instalasi hingga Akses Database“Bermain” dengan Code Igniter FULL : Instalasi hingga Akses Database
  • Login Multi-User dengan PHP dan MysqlLogin Multi-User dengan PHP dan Mysql
  • Tutorial to Create Simple Tabs-AJAX with AJAX and PHPTutorial to Create Simple Tabs-AJAX with AJAX and PHP
  • Tutorial Image Uploading, Saving and Showing.Tutorial Image Uploading, Saving and Showing.
  • PHP Form Input Date with Datetimepicker JQueryPHP Form Input Date with Datetimepicker JQuery
  • Get the Data from Database with Codeigniter and Show it with JQuery UI TabGet the Data from Database with Codeigniter and Show it with JQuery UI Tab

Artikel terkait:

  • Login Multi-User dengan PHP dan Mysql
  • Menjalankan Query SQL via PHP
  • Create a Pagination in CodeIgniter
  • Simple Mobile Programming with PHP and DeviceAtlas
  • Mendapatkan Feed Situs lain Via RSS Reader SimplePie
: PHP
: login multi user, mysql, PHP

About the author

obviously, a girl. with sweet smile, off course. turning her 21 years trapped on Informatics departement and just started to having some crush with it lately. she uses wordpress. she loves php. she lo
littleflow3r.wordpress.com/

2 Comments

  • afrilia berkata:
    Februari 20, 2012 pukul 3:54 pm

    (scenic)
    bagus bgt ne…patut dicoba

    Balas
  • mamachineapain.com berkata:
    Juli 15, 2015 pukul 3:48 pm

    Thankfulness to my father who informed me regarding this blog,
    this blog is in fact awesome.

    Balas

Tinggalkan Balasan Batalkan balasan

Alamat email Anda tidak akan dipublikasikan. Ruas yang wajib ditandai *

x( X-( B-) ;-) :wink: :twisted: :roll: :oops: :mrgreen: :lol: :idea: :evil: :cry: :arrow: :D :?: :-| :-x :-o :-P :-D :-? :-)) :-) :-( :-& :) :( :!: 8-O 8-) 8) (Русский) (yahoo) (worship) (woot) (wave) (unsure) (tongue) (thinking) (tears) (taser) (smileydance) (sleeping) (sick) (scenic) (rofl) (rock) (party) (panic) (okok) (nottalking) (ninja) (music) (muscle) (muhaha) (money) (mmm) (lonely) (lol) (lmao) (idiot) (hungry) (highfive) (heart_beat) (heart) (headspin) (hassle) (haha) (gym) (griltongue) (goodluck) (girlkiss) (funkydance) (fish_hit) (eyeroll) (evilsmirk) (evil_grin) (drinking) (doh) (devil) (dance) (cry) (cozy) (coffee) (brokenheart) (bringit) (blush) (bigeyes) (beer) (banana_rock) (banana_ninja) (banana_cool) (applause) (annoyed) (angry) (K) (:

RSS feed for this post (comments) · TrackBack URI
Previous Post
« Login Multi-User dengan PHP dan Mysql
Next Post
Google Calendar di WordPress »
  • Like itx.web.id?
  • Jam Kayu Unik
  • Search

    • Hai
    • Posts
    • Comments
    Inilah blog itx.... seorang yang suka pemrograman web khususnya PHP dan WordPress... jangan ragu tinggalkan pesan di sini ... :)
    Sebagian besar artikel di sini tidak saya tulis, melainkan ditulis oleh teman-teman author (penulis lepas). Jadi kalo menyapa jangan salah alamat yaaa... lihat dulu siapa penulis artikel ybs.
    • Digampar kucing ataukah digampar pakai Kucing?
    • Tips membaca Alquran dengan mudah untuk yang kesulitan membaca Alquran dengan lancar
    • Ksatria Pandawa Lima: Mahabarata versi Jawa setengah hati
    • Create Multi-User in WordPress CMS
    • Membuat Multi-user dalam CMS WordPress
    • Instant Sorting Function with PHP
    • Fungsi Sorting (Pengurutan) Instan dengan PHP
    • Installing New Theme in WordPress CMS
    • Menginstall Tema Baru dalam CMS WordPress
    • Create Page (Statis Post) in WordPress (Beginner Only)
    • Rzl: Saya juga gag lancar bacanya..bikin males baca. Mungkin dengan tips ini bisa membantu saya.. Mksih buat tipsnya
    • Wndy: MaasyaaAllah, anak laki-laki saya 11 th setipe...semoga Allah mudahkan ia lancar membaca dan menghafal Al Quran. Trims tipsnya..Juga untuk…
    • Fadelgutanio: nice tutor,broo :wink: :wink:
    • Facebook Customer Service Number: Great Info really keep it up.
    • Michal: Thanks for sharing this rare information. keep it up Get help for QuickBooks: https://www.wizxpert.com/quickbooks-enterprise-support/
    • QuickBooks ProAdvisor: Thanks for sharing the information. Keep posting.
    • QuickBooks Integration Support: Thanks for such a good articles it really helped me after reading your posts
    • wewpyou: We are a team of highly experienced WP professionals with remarkable knowledge. We lend our expertise to SMEs by providing…
    • QuickBooks Proadvisor Support: This guide is really amazing as it has simplified a lot of queries for me. You present your research openly…
    • james: nice blog (smileydance)
    • qasolved: Quickbooks error codes 80029c4a is an error that happens while opening a company file. The error message is potentially caused…
    • QuickBooks File Doctor: I really appreciate this. Thanks for the sharing. If you need information about QuickBooks, contact QuickBooks file…
    • wewpyou: We are a team of highly experienced WP professionals with remarkable knowledge. We lend our expertise to SMEs by providing…
    • wewpyou: We are a team of highly experienced WP professionals with remarkable knowledge. We lend our expertise to SMEs by providing…
    • quickbooks pro help: QuickBooks Pro is Desktop version which is best suited for SMEs and startups. We specialize in providing QuickBooks Pro related…
  • Postingan populer

    • Tips membaca Alquran dengan mudah untuk yang kesulitan membaca Alquran dengan lancar
    • Tutorial Searching / Pencarian Data dengan PHP dan Mysql
    • Tutorial Upload, Menyimpan, dan Menampilkan Gambar dengan PHP dan Mysql
    • Membuat Form ComboBox Dinamis dari Database (Mysql) dengan PHP
    • Membuat Fungsi Update Data dalam Database dengan PHP Mysql
    • Penggunaan Fungsi Date / Time pada PHP
    • Form Input Tanggal PHP dengan Datetimepicker JQuery
  • Tag

    ajax ajax tab basic cms wordpress codeigniter codeigniter export to excel date function device recognition effect fadeout form validation free wordpress theme fun mode GPL JavaScript JavaScript Library jQuery jquery UI kelirumologi login multi user mobile programming multisite mysql mysql to excel OpenID pagination paging parse xml with php personal settings PHP php string post posting code posting sourcecode splitting content surprise me syntax highlighter theme users WordPress wordpress.com wordpress mobile wordpress plugin wordpress theme xml to mysql
  • Theme Buatan itx

    Albizia Theme
    - Download Albizia

    Bombax Theme
    - Download Bombax

    Calotropis Theme
    - Download Calotropis

  • Plugin Buatan itx

    Exclude Plugins
    - Download Exclude Plugins

  • Jika memiliki pertanyaan tentang theme atau plugin buatan itx, silahkan menuju forum.
  • Lampu Kayu
    Jelajah Bumi
itx si tukang kritix
Bombax Theme designed by itx