SlideShare a Scribd company logo
<?php
// mulai session
session_start();
?>
<!DOCTYPE html>
<html>
<body>
<?php
// set variable pada session
$_SESSION["favcolor"] = “hijau";
$_SESSION["favanimal"] = “kucing";
echo “Variabel telah dibuat.";
?>
</body>
</html>
<?php
session_start();
?>
<!DOCTYPE html>
<html>
<body>
<?php
// menampilkan variable yang dibuat sebelumnya
echo “Warna favorit adalah " . $_SESSION["favcolor"] .
".<br>";
echo “Binatang peliharaan favorit adalah " .
$_SESSION["favanimal"] . ".";
?>
</body>
</html>
<?php
session_start();
?>
<!DOCTYPE html>
<html>
<body>
<?php
// menghapus semua variable yang di set
session_unset();
// menghapus/menghancurkan session
session_destroy();
?>
</body>
</html>
<?php
mysql_connect("localhost","root","") or die
("Gagal Terhubung Ke Database");
mysql_select_db(“dbtes") or die ("Database
Tidak Ditemukan");
?>
<form class="form-horizontal" method="post" name="pendaftaran" action="registrasi.php">
<div class="form-group">
<label class="control-label col-sm-2" for="name">Nama:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="nama" placeholder="masukkan nama" name="nama">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="name">Email:</label>
<div class="col-sm-10">
<input type="email" class="form-control" id="email" placeholder="masukkan email" name="email">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="name">Username:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="username" placeholder="masukkan username" name="username">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="pwd">Password:</label>
<div class="col-sm-10">
<input type="password" class="form-control" id="password" placeholder="masukkan password" name="password">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<input class="btn btn-primary" type="submit" name="submit" value="DAFTAR">
</div>
</div>
</form>
<?php
include "koneksi.php";
$nama = $_POST['nama'];
$email = $_POST['email'];
$username = $_POST['username'];
$password = $_POST['password'];
if (empty($nama)){
echo "<script>alert('Nama belum diisi')</script>";
echo "<meta http-equiv='refresh' content='1 url=daftar.php'>";
}else
if (empty($email)){
echo "<script>alert('Email belum diisi')</script>";
echo "<meta http-equiv='refresh' content='1 url=daftar.php'>";
}else
if(empty($username)){
echo "<script>alert('Username belum diisi')</script>";
echo "<meta http-equiv='refresh' content='1 url=daftar.php'>";
}else
if (empty($password)){
echo "<script>alert('Password belum diisi')</script>";
echo "<meta http-equiv='refresh' content='1 url=daftar.php'>";
}else{
$daftar = mysql_query("INSERT INTO pengguna (id_user,nama,username,password) values
('$nama','$email','$username','$password')");
if ($daftar){
echo "<script>alert('Berhasil Mendaftar')</script>";
echo "<meta http-equiv='refresh' content='1 url=daftar.php'>";
}else{
echo "<script>alert('Gagal Mendaftar')</script>";
echo "<meta http-equiv='refresh' content='1 url=daftar.php'>";
}
}
?>
<?php
include "koneksi.php";
session_start();
if (isset($_SESSION['username'])){
header ("location:index.php");
}
?>
<div class="container">
<div class="page-header">
<h1><b>Form Masuk Akun</b></h1>
<br />
</div>
<br />
<form class="form-horizontal" method="post" name="login" action="logincek.php">
<div class="form-group">
<label class="control-label col-sm-2" for="email">Username:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="username" placeholder="masukkan username" name="username">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="pwd">Password:</label>
<div class="col-sm-10">
<input type="password" class="form-control" id="password" placeholder="Enter password" name="password">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-default" value="LOGIN">Masuk</button>
</div>
</div>
</form>
</div>
<?php
include "koneksi.php";
$username = $_POST['username'];
$password = $_POST['password'];
if (empty($username)){
echo "<script>alert('Username belum diisi')</script>";
echo "<meta http-equiv='refresh' content='1 url=login.php'>";
}else if (empty($password)){
echo "<script>alert('Password belum diisi')</script>";
echo "<meta http-equiv='refresh' content='1 url=login.php'>";
}else{
session_start();
$login = mysql_query("select * from pengguna where
username='$username' and password='$password'");
if (mysql_num_rows($login) > 0){
$_SESSION['username'] = $username;
header("location:index.php");
}else{
echo "<script>alert('Username atau Password salah')</script>";
echo "<meta http-equiv='refresh' content='1 url=login.php'>";
}
}
?>
<?php
include "koneksi.php";
session_start();
if (!isset($_SESSION['username'])){
header ("location:login.php");
}
?>
Berhasil Login, <a href="logout.php">Logout</a>
<?php
session_start();
session_destroy();
echo "<script>alert('Terima kasih, Anda Berhasil
Logout')</script>";
echo "<meta http-equiv='refresh' content='1
url=login.php'>";
?>

More Related Content

What's hot

Coding for php with mysql
Coding for php with mysqlCoding for php with mysql
Coding for php with mysql
Rajamanickam Gomathijayam
 
London XQuery Meetup: Querying the World (Web Scraping)
London XQuery Meetup: Querying the World (Web Scraping)London XQuery Meetup: Querying the World (Web Scraping)
London XQuery Meetup: Querying the World (Web Scraping)
Dennis Knochenwefel
 
Check username availability with vue.js and PHP
Check username availability with vue.js and PHPCheck username availability with vue.js and PHP
Check username availability with vue.js and PHP
Yogesh singh
 
Not Really PHP by the book
Not Really PHP by the bookNot Really PHP by the book
Not Really PHP by the book
Ryan Kilfedder
 
Future of HTTP in CakePHP
Future of HTTP in CakePHPFuture of HTTP in CakePHP
Future of HTTP in CakePHP
markstory
 
New in cakephp3
New in cakephp3New in cakephp3
New in cakephp3
markstory
 
Karan chanana
Karan chananaKaran chanana
Karan chanana
karan chanana
 
TICT #13
TICT #13TICT #13
TICT #13
azman_awan9
 
TICT #11
TICT #11 TICT #11
TICT #11
azman_awan9
 
Jqeury ajax plugins
Jqeury ajax pluginsJqeury ajax plugins
Jqeury ajax pluginsInbal Geffen
 
Advanced Querying with CakePHP 3
Advanced Querying with CakePHP 3Advanced Querying with CakePHP 3
Advanced Querying with CakePHP 3
José Lorenzo Rodríguez Urdaneta
 
Cpsh sh
Cpsh shCpsh sh
Cpsh sh
Ben Pope
 
PHP an intro -1
PHP an intro -1PHP an intro -1
PHP an intro -1Kanchilug
 
Pagination in PHP
Pagination in PHPPagination in PHP
Pagination in PHP
Vineet Kumar Saini
 
8時間耐久CakePHP2 勉強会
8時間耐久CakePHP2 勉強会8時間耐久CakePHP2 勉強会
8時間耐久CakePHP2 勉強会
Yusuke Ando
 

What's hot (18)

Coding for php with mysql
Coding for php with mysqlCoding for php with mysql
Coding for php with mysql
 
Php
PhpPhp
Php
 
London XQuery Meetup: Querying the World (Web Scraping)
London XQuery Meetup: Querying the World (Web Scraping)London XQuery Meetup: Querying the World (Web Scraping)
London XQuery Meetup: Querying the World (Web Scraping)
 
Check username availability with vue.js and PHP
Check username availability with vue.js and PHPCheck username availability with vue.js and PHP
Check username availability with vue.js and PHP
 
Perl5i
Perl5iPerl5i
Perl5i
 
Not Really PHP by the book
Not Really PHP by the bookNot Really PHP by the book
Not Really PHP by the book
 
Future of HTTP in CakePHP
Future of HTTP in CakePHPFuture of HTTP in CakePHP
Future of HTTP in CakePHP
 
New in cakephp3
New in cakephp3New in cakephp3
New in cakephp3
 
Karan chanana
Karan chananaKaran chanana
Karan chanana
 
TICT #13
TICT #13TICT #13
TICT #13
 
TICT #11
TICT #11 TICT #11
TICT #11
 
Jqeury ajax plugins
Jqeury ajax pluginsJqeury ajax plugins
Jqeury ajax plugins
 
Advanced Querying with CakePHP 3
Advanced Querying with CakePHP 3Advanced Querying with CakePHP 3
Advanced Querying with CakePHP 3
 
Cpsh sh
Cpsh shCpsh sh
Cpsh sh
 
PHP an intro -1
PHP an intro -1PHP an intro -1
PHP an intro -1
 
Coding website
Coding websiteCoding website
Coding website
 
Pagination in PHP
Pagination in PHPPagination in PHP
Pagination in PHP
 
8時間耐久CakePHP2 勉強会
8時間耐久CakePHP2 勉強会8時間耐久CakePHP2 勉強会
8時間耐久CakePHP2 勉強会
 

Similar to Pemrograman Web 9 - Input Form DB dan Session

Html , php, mysql intro
Html , php, mysql introHtml , php, mysql intro
Html , php, mysql intro
Nagarajan Kamalakannan
 
Php update and delet operation
Php update and delet operationPhp update and delet operation
Php update and delet operation
syeda zoya mehdi
 
PHP POWERPOINT SLIDES
PHP POWERPOINT SLIDESPHP POWERPOINT SLIDES
PHP POWERPOINT SLIDES
Ismail Mukiibi
 
User registration and login using stored procedure in php
User registration and login using stored procedure in phpUser registration and login using stored procedure in php
User registration and login using stored procedure in php
PHPGurukul Blog
 
Daily notes
Daily notesDaily notes
Daily notes
meghendra168
 
18.register login
18.register login18.register login
18.register login
Razvan Raducanu, PhD
 
Blog Hacks 2011
Blog Hacks 2011Blog Hacks 2011
Blog Hacks 2011
Yusuke Wada
 
logic321
logic321logic321
logic321
logic321
 
how would i fix my code- any login doesnt work but it should retrieve.docx
how would i fix my code- any login doesnt work but it should retrieve.docxhow would i fix my code- any login doesnt work but it should retrieve.docx
how would i fix my code- any login doesnt work but it should retrieve.docx
JacobUasThomsoni
 
Advanced php testing in action
Advanced php testing in actionAdvanced php testing in action
Advanced php testing in action
Jace Ju
 
R57shell
R57shellR57shell
R57shell
ady36
 
Web 8 | Introduction to PHP
Web 8 | Introduction to PHPWeb 8 | Introduction to PHP
Web 8 | Introduction to PHP
Mohammad Imam Hossain
 
php is the most important programming language
php is the most important programming languagephp is the most important programming language
php is the most important programming language
padmanabanm47
 
Zero to SOLID
Zero to SOLIDZero to SOLID
Zero to SOLID
Vic Metcalfe
 
Mike King - Storytelling by Numbers MKTFEST 2014
Mike King - Storytelling by Numbers MKTFEST 2014Mike King - Storytelling by Numbers MKTFEST 2014
Mike King - Storytelling by Numbers MKTFEST 2014
Marketing Festival
 
Storytelling By Numbers
Storytelling By NumbersStorytelling By Numbers
Storytelling By Numbers
Michael King
 
Latihan form login
Latihan form loginLatihan form login
Latihan form login
Edy Sinaga
 
Unit 3 - for php application Sessions.pptx
Unit 3  -  for php  application Sessions.pptxUnit 3  -  for php  application Sessions.pptx
Unit 3 - for php application Sessions.pptx
mythili213835
 
Php tutorial handout
Php tutorial handoutPhp tutorial handout
Php tutorial handoutSBalan Balan
 

Similar to Pemrograman Web 9 - Input Form DB dan Session (20)

Html , php, mysql intro
Html , php, mysql introHtml , php, mysql intro
Html , php, mysql intro
 
Php update and delet operation
Php update and delet operationPhp update and delet operation
Php update and delet operation
 
PHP POWERPOINT SLIDES
PHP POWERPOINT SLIDESPHP POWERPOINT SLIDES
PHP POWERPOINT SLIDES
 
Php (1)
Php (1)Php (1)
Php (1)
 
User registration and login using stored procedure in php
User registration and login using stored procedure in phpUser registration and login using stored procedure in php
User registration and login using stored procedure in php
 
Daily notes
Daily notesDaily notes
Daily notes
 
18.register login
18.register login18.register login
18.register login
 
Blog Hacks 2011
Blog Hacks 2011Blog Hacks 2011
Blog Hacks 2011
 
logic321
logic321logic321
logic321
 
how would i fix my code- any login doesnt work but it should retrieve.docx
how would i fix my code- any login doesnt work but it should retrieve.docxhow would i fix my code- any login doesnt work but it should retrieve.docx
how would i fix my code- any login doesnt work but it should retrieve.docx
 
Advanced php testing in action
Advanced php testing in actionAdvanced php testing in action
Advanced php testing in action
 
R57shell
R57shellR57shell
R57shell
 
Web 8 | Introduction to PHP
Web 8 | Introduction to PHPWeb 8 | Introduction to PHP
Web 8 | Introduction to PHP
 
php is the most important programming language
php is the most important programming languagephp is the most important programming language
php is the most important programming language
 
Zero to SOLID
Zero to SOLIDZero to SOLID
Zero to SOLID
 
Mike King - Storytelling by Numbers MKTFEST 2014
Mike King - Storytelling by Numbers MKTFEST 2014Mike King - Storytelling by Numbers MKTFEST 2014
Mike King - Storytelling by Numbers MKTFEST 2014
 
Storytelling By Numbers
Storytelling By NumbersStorytelling By Numbers
Storytelling By Numbers
 
Latihan form login
Latihan form loginLatihan form login
Latihan form login
 
Unit 3 - for php application Sessions.pptx
Unit 3  -  for php  application Sessions.pptxUnit 3  -  for php  application Sessions.pptx
Unit 3 - for php application Sessions.pptx
 
Php tutorial handout
Php tutorial handoutPhp tutorial handout
Php tutorial handout
 

More from Nur Fadli Utomo

Desain Grafis 6 - UI/UX on Web Application
Desain Grafis 6 - UI/UX on Web ApplicationDesain Grafis 6 - UI/UX on Web Application
Desain Grafis 6 - UI/UX on Web Application
Nur Fadli Utomo
 
Pemrograman Web 7 - Basic PHP
Pemrograman Web 7 - Basic PHPPemrograman Web 7 - Basic PHP
Pemrograman Web 7 - Basic PHP
Nur Fadli Utomo
 
Pemrograman Web 6 - jQuery
Pemrograman Web 6 - jQueryPemrograman Web 6 - jQuery
Pemrograman Web 6 - jQuery
Nur Fadli Utomo
 
Pemrograman Web 5 - Javascript
Pemrograman Web 5 - JavascriptPemrograman Web 5 - Javascript
Pemrograman Web 5 - Javascript
Nur Fadli Utomo
 
Desain Grafis 5 - Good Graphic Design
Desain Grafis 5 - Good Graphic DesignDesain Grafis 5 - Good Graphic Design
Desain Grafis 5 - Good Graphic Design
Nur Fadli Utomo
 
Desain Grafis 3 - Color
Desain Grafis 3 - ColorDesain Grafis 3 - Color
Desain Grafis 3 - Color
Nur Fadli Utomo
 
Desain Grafis 4 - UI/UX
Desain Grafis 4 - UI/UXDesain Grafis 4 - UI/UX
Desain Grafis 4 - UI/UX
Nur Fadli Utomo
 
Pemrograman Web 4 - Bootstrap 3
Pemrograman Web 4 - Bootstrap 3Pemrograman Web 4 - Bootstrap 3
Pemrograman Web 4 - Bootstrap 3
Nur Fadli Utomo
 
Pemrograman Web 3 - CSS Basic Part 2
Pemrograman Web 3 - CSS Basic Part 2Pemrograman Web 3 - CSS Basic Part 2
Pemrograman Web 3 - CSS Basic Part 2
Nur Fadli Utomo
 
Desain Grafis 2 - Kerning Type
Desain Grafis 2 - Kerning TypeDesain Grafis 2 - Kerning Type
Desain Grafis 2 - Kerning Type
Nur Fadli Utomo
 
Desain Grafis 1 - Basic
Desain Grafis 1 - BasicDesain Grafis 1 - Basic
Desain Grafis 1 - Basic
Nur Fadli Utomo
 
Pemrograman Web 2 - CSS
Pemrograman Web 2 - CSSPemrograman Web 2 - CSS
Pemrograman Web 2 - CSS
Nur Fadli Utomo
 
Pemrograman Web - HTML
Pemrograman Web - HTMLPemrograman Web - HTML
Pemrograman Web - HTML
Nur Fadli Utomo
 
PC 9 - Matlab 2nd Chapter
PC 9 - Matlab 2nd ChapterPC 9 - Matlab 2nd Chapter
PC 9 - Matlab 2nd Chapter
Nur Fadli Utomo
 
PC 8 - Matlab
PC 8 - MatlabPC 8 - Matlab
PC 8 - Matlab
Nur Fadli Utomo
 
Pengolahan Citra 7 - Warna
Pengolahan Citra 7 - WarnaPengolahan Citra 7 - Warna
Pengolahan Citra 7 - Warna
Nur Fadli Utomo
 
GK 3 Penggambaran Titik dan Garis
GK 3   Penggambaran Titik dan GarisGK 3   Penggambaran Titik dan Garis
GK 3 Penggambaran Titik dan Garis
Nur Fadli Utomo
 
Citra Biner
Citra BinerCitra Biner
Citra Biner
Nur Fadli Utomo
 
Pengolahan Citra 4 - Histogram Citra
Pengolahan Citra 4 - Histogram CitraPengolahan Citra 4 - Histogram Citra
Pengolahan Citra 4 - Histogram Citra
Nur Fadli Utomo
 
Pengolahan Citra 3 - Operasi-operasi Digital
Pengolahan Citra 3 - Operasi-operasi DigitalPengolahan Citra 3 - Operasi-operasi Digital
Pengolahan Citra 3 - Operasi-operasi Digital
Nur Fadli Utomo
 

More from Nur Fadli Utomo (20)

Desain Grafis 6 - UI/UX on Web Application
Desain Grafis 6 - UI/UX on Web ApplicationDesain Grafis 6 - UI/UX on Web Application
Desain Grafis 6 - UI/UX on Web Application
 
Pemrograman Web 7 - Basic PHP
Pemrograman Web 7 - Basic PHPPemrograman Web 7 - Basic PHP
Pemrograman Web 7 - Basic PHP
 
Pemrograman Web 6 - jQuery
Pemrograman Web 6 - jQueryPemrograman Web 6 - jQuery
Pemrograman Web 6 - jQuery
 
Pemrograman Web 5 - Javascript
Pemrograman Web 5 - JavascriptPemrograman Web 5 - Javascript
Pemrograman Web 5 - Javascript
 
Desain Grafis 5 - Good Graphic Design
Desain Grafis 5 - Good Graphic DesignDesain Grafis 5 - Good Graphic Design
Desain Grafis 5 - Good Graphic Design
 
Desain Grafis 3 - Color
Desain Grafis 3 - ColorDesain Grafis 3 - Color
Desain Grafis 3 - Color
 
Desain Grafis 4 - UI/UX
Desain Grafis 4 - UI/UXDesain Grafis 4 - UI/UX
Desain Grafis 4 - UI/UX
 
Pemrograman Web 4 - Bootstrap 3
Pemrograman Web 4 - Bootstrap 3Pemrograman Web 4 - Bootstrap 3
Pemrograman Web 4 - Bootstrap 3
 
Pemrograman Web 3 - CSS Basic Part 2
Pemrograman Web 3 - CSS Basic Part 2Pemrograman Web 3 - CSS Basic Part 2
Pemrograman Web 3 - CSS Basic Part 2
 
Desain Grafis 2 - Kerning Type
Desain Grafis 2 - Kerning TypeDesain Grafis 2 - Kerning Type
Desain Grafis 2 - Kerning Type
 
Desain Grafis 1 - Basic
Desain Grafis 1 - BasicDesain Grafis 1 - Basic
Desain Grafis 1 - Basic
 
Pemrograman Web 2 - CSS
Pemrograman Web 2 - CSSPemrograman Web 2 - CSS
Pemrograman Web 2 - CSS
 
Pemrograman Web - HTML
Pemrograman Web - HTMLPemrograman Web - HTML
Pemrograman Web - HTML
 
PC 9 - Matlab 2nd Chapter
PC 9 - Matlab 2nd ChapterPC 9 - Matlab 2nd Chapter
PC 9 - Matlab 2nd Chapter
 
PC 8 - Matlab
PC 8 - MatlabPC 8 - Matlab
PC 8 - Matlab
 
Pengolahan Citra 7 - Warna
Pengolahan Citra 7 - WarnaPengolahan Citra 7 - Warna
Pengolahan Citra 7 - Warna
 
GK 3 Penggambaran Titik dan Garis
GK 3   Penggambaran Titik dan GarisGK 3   Penggambaran Titik dan Garis
GK 3 Penggambaran Titik dan Garis
 
Citra Biner
Citra BinerCitra Biner
Citra Biner
 
Pengolahan Citra 4 - Histogram Citra
Pengolahan Citra 4 - Histogram CitraPengolahan Citra 4 - Histogram Citra
Pengolahan Citra 4 - Histogram Citra
 
Pengolahan Citra 3 - Operasi-operasi Digital
Pengolahan Citra 3 - Operasi-operasi DigitalPengolahan Citra 3 - Operasi-operasi Digital
Pengolahan Citra 3 - Operasi-operasi Digital
 

Recently uploaded

Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 
Visitor Management System in India- Vizman.app
Visitor Management System in India- Vizman.appVisitor Management System in India- Vizman.app
Visitor Management System in India- Vizman.app
NaapbooksPrivateLimi
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
informapgpstrackings
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Globus
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
IES VE
 
De mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEDe mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FME
Jelle | Nordend
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
WSO2
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Globus
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
takuyayamamoto1800
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
Globus
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
kalichargn70th171
 
Strategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptxStrategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptx
varshanayak241
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should Know
Peter Caitens
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
Georgi Kodinov
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
Juraj Vysvader
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2
 

Recently uploaded (20)

Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 
Visitor Management System in India- Vizman.app
Visitor Management System in India- Vizman.appVisitor Management System in India- Vizman.app
Visitor Management System in India- Vizman.app
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 
De mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEDe mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FME
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
 
Strategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptxStrategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptx
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should Know
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 

Pemrograman Web 9 - Input Form DB dan Session

  • 1.
  • 2.
  • 3. <?php // mulai session session_start(); ?> <!DOCTYPE html> <html> <body> <?php // set variable pada session $_SESSION["favcolor"] = “hijau"; $_SESSION["favanimal"] = “kucing"; echo “Variabel telah dibuat."; ?> </body> </html>
  • 4.
  • 5. <?php session_start(); ?> <!DOCTYPE html> <html> <body> <?php // menampilkan variable yang dibuat sebelumnya echo “Warna favorit adalah " . $_SESSION["favcolor"] . ".<br>"; echo “Binatang peliharaan favorit adalah " . $_SESSION["favanimal"] . "."; ?> </body> </html>
  • 6.
  • 7. <?php session_start(); ?> <!DOCTYPE html> <html> <body> <?php // menghapus semua variable yang di set session_unset(); // menghapus/menghancurkan session session_destroy(); ?> </body> </html>
  • 8.
  • 9.
  • 10. <?php mysql_connect("localhost","root","") or die ("Gagal Terhubung Ke Database"); mysql_select_db(“dbtes") or die ("Database Tidak Ditemukan"); ?>
  • 11. <form class="form-horizontal" method="post" name="pendaftaran" action="registrasi.php"> <div class="form-group"> <label class="control-label col-sm-2" for="name">Nama:</label> <div class="col-sm-10"> <input type="text" class="form-control" id="nama" placeholder="masukkan nama" name="nama"> </div> </div> <div class="form-group"> <label class="control-label col-sm-2" for="name">Email:</label> <div class="col-sm-10"> <input type="email" class="form-control" id="email" placeholder="masukkan email" name="email"> </div> </div>
  • 12. <div class="form-group"> <label class="control-label col-sm-2" for="name">Username:</label> <div class="col-sm-10"> <input type="text" class="form-control" id="username" placeholder="masukkan username" name="username"> </div> </div> <div class="form-group"> <label class="control-label col-sm-2" for="pwd">Password:</label> <div class="col-sm-10"> <input type="password" class="form-control" id="password" placeholder="masukkan password" name="password"> </div> </div> <div class="form-group"> <div class="col-sm-offset-2 col-sm-10"> <input class="btn btn-primary" type="submit" name="submit" value="DAFTAR"> </div> </div> </form>
  • 13. <?php include "koneksi.php"; $nama = $_POST['nama']; $email = $_POST['email']; $username = $_POST['username']; $password = $_POST['password']; if (empty($nama)){ echo "<script>alert('Nama belum diisi')</script>"; echo "<meta http-equiv='refresh' content='1 url=daftar.php'>"; }else if (empty($email)){ echo "<script>alert('Email belum diisi')</script>"; echo "<meta http-equiv='refresh' content='1 url=daftar.php'>"; }else
  • 14. if(empty($username)){ echo "<script>alert('Username belum diisi')</script>"; echo "<meta http-equiv='refresh' content='1 url=daftar.php'>"; }else if (empty($password)){ echo "<script>alert('Password belum diisi')</script>"; echo "<meta http-equiv='refresh' content='1 url=daftar.php'>"; }else{ $daftar = mysql_query("INSERT INTO pengguna (id_user,nama,username,password) values ('$nama','$email','$username','$password')"); if ($daftar){ echo "<script>alert('Berhasil Mendaftar')</script>"; echo "<meta http-equiv='refresh' content='1 url=daftar.php'>"; }else{ echo "<script>alert('Gagal Mendaftar')</script>"; echo "<meta http-equiv='refresh' content='1 url=daftar.php'>"; } } ?>
  • 15. <?php include "koneksi.php"; session_start(); if (isset($_SESSION['username'])){ header ("location:index.php"); } ?> <div class="container"> <div class="page-header"> <h1><b>Form Masuk Akun</b></h1> <br /> </div> <br /> <form class="form-horizontal" method="post" name="login" action="logincek.php"> <div class="form-group"> <label class="control-label col-sm-2" for="email">Username:</label>
  • 16. <div class="col-sm-10"> <input type="text" class="form-control" id="username" placeholder="masukkan username" name="username"> </div> </div> <div class="form-group"> <label class="control-label col-sm-2" for="pwd">Password:</label> <div class="col-sm-10"> <input type="password" class="form-control" id="password" placeholder="Enter password" name="password"> </div> </div> <div class="form-group"> <div class="col-sm-offset-2 col-sm-10"> <button type="submit" class="btn btn-default" value="LOGIN">Masuk</button> </div> </div> </form> </div>
  • 17. <?php include "koneksi.php"; $username = $_POST['username']; $password = $_POST['password']; if (empty($username)){ echo "<script>alert('Username belum diisi')</script>"; echo "<meta http-equiv='refresh' content='1 url=login.php'>"; }else if (empty($password)){ echo "<script>alert('Password belum diisi')</script>"; echo "<meta http-equiv='refresh' content='1 url=login.php'>"; }else{
  • 18. session_start(); $login = mysql_query("select * from pengguna where username='$username' and password='$password'"); if (mysql_num_rows($login) > 0){ $_SESSION['username'] = $username; header("location:index.php"); }else{ echo "<script>alert('Username atau Password salah')</script>"; echo "<meta http-equiv='refresh' content='1 url=login.php'>"; } } ?>
  • 19. <?php include "koneksi.php"; session_start(); if (!isset($_SESSION['username'])){ header ("location:login.php"); } ?> Berhasil Login, <a href="logout.php">Logout</a>
  • 20. <?php session_start(); session_destroy(); echo "<script>alert('Terima kasih, Anda Berhasil Logout')</script>"; echo "<meta http-equiv='refresh' content='1 url=login.php'>"; ?>