How to create login form using PHP - MySQL

in #utopian-io6 years ago (edited)

What Will I Learn?

  • You can learn how to create login form
  • you can make your website more secure
  • will also be able to create other forms

Requirements

  • you must understand basic-php basis
  • you must understand the basics of mySQL
  • you should be able to make a connection between php and mySQL

Difficulty

  • Basic

Tutorial Contents

login process is needed in a site, this time I will give tutorial how to make login form, create a login form with php mySQL is often we find on the big websites that exist in the world,
for example facebook, instagram and others, for beginners programmers definitely think that it is very difficult to create a login form like facebook or instagram. actually it is very easy, you just have to do the steps below.
steps in creating login form:

  1. first you must create a database in which stored username and password so that can not be accessed by another.
  • write the following code in mySQL, this code is the command to create a database:
    CREATE DATABASE IF NOT EXISTS tes_db /*!40100 DEFAULT CHARACTER SET latin1 */;
    USE tes_db;

    q.png
    notice the database is created

  • tuliskan code untuk membuat tabel dalam database yang di dalamnya terdapat username dan password
    CREATE TABLE IF NOT EXISTS karyawan (
    id_karyawan int(10) NOT NULL AUTO_INCREMENT,
    pass_karyawan varchar(50) NOT NULL DEFAULT '0',
    user_karyawan varchar(50) NOT NULL DEFAULT '0',
    nama_karyawan varchar(50) DEFAULT NULL,
    alm_karyawan varchar(50) DEFAULT NULL,
    gaji_karyawan int(10) DEFAULT NULL,
    tgl_gabung date DEFAULT NULL,
    PRIMARY KEY (id_karyawan)
    ) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=latin1;

    q.png
    notice the tabel has been created

  • The next step is to enter the username and password into the table that has been created
    INSERT IGNORE INTO karyawan (id_karyawan, pass_karyawan, user_karyawan, nama_karyawan, alm_karyawan, gaji_karyawan, tgl_gabung) VALUES
    (1, '1234', 'admin', 'Admin Nyekrip', 'Website', 3000000, '2015-04-16'),
    (2, '4321', 'staf', 'Staf Nyekrip', 'Server Web', 250000, '2015-04-16');
    q.png
    notice the user data has been entered into the table

  1. the next step is to design login form using PHP
    if(isset($_SESSION['login_user'])){
    header("location: profile.php");
    }
    ?>


            <label>Username :</label>
            <input id="name" name="username" placeholder="username" type="text">
            
            <label>Password :</label>
            <input id="password" name="password" placeholder="**********" type="password">
            
            <input type="submit" name="submit" id="submit" value="Login">
          </form>
        </div>
    


q.png
display login form that we have created


  • okay login form we created successfully, then we will connect our form with our database


if this page appears it means we have successfully login



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Thank you for the contribution. It has been approved.

You can contact us on Discord.
[utopian-moderator]

Hey @lapulga I am @utopian-io. I have just upvoted you!

Achievements

  • You have less than 500 followers. Just gave you a gift to help you succeed!
  • Seems like you contribute quite often. AMAZING!

Suggestions

  • Contribute more often to get higher and higher rewards. I wish to see you often!
  • Work on your followers to increase the votes/rewards. I follow what humans do and my vote is mainly based on that. Good luck!

Get Noticed!

  • Did you know project owners can manually vote with their own voting power or by voting power delegated to their projects? Ask the project owner to review your contributions!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

Coin Marketplace

STEEM 0.33
TRX 0.11
JST 0.035
BTC 67020.94
ETH 3270.13
USDT 1.00
SBD 4.62