How to create login form using PHP - MySQL
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:
- 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 */;
USEtes_db
;
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;
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 INTOkaryawan
(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');
notice the user data has been entered into the table
- 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>
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
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
Suggestions
Get Noticed!
Community-Driven Witness!
I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!
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