membuat sebuah sistem masuk keren dengan php, mysql & jquery

34
Membuat Sebuah Sistem Masuk Keren Dengan PHP, MySQL & jQuery Pengantar Hari ini kita membuat suatu sistem login / pendaftaran keren & sederhana. Ini akan memberi Anda kemampuan untuk dengan mudah membuat area anggota-satunya di situs Anda dan memberikan proses pendaftaran mudah. Hal ini akan menjadi PHP didorong dan menyimpan semua pendaftaran ke dalam database MySQL. Untuk menambahkan bakat yang dibutuhkan, kita menggunakan menakjubkan panel jQuery geser , yang dikembangkan oleh Web- kreation . Langkah 1 - MySQL Pertama kita harus membuat tabel yang akan menampung semua pendaftaran. Kode ini tersedia dalam table.sql. table.sql 01 <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">--</span> -</span> 02 <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">-- Table structure for table `tz_members`</span> - Tabel struktur untuk tz_members tabel `</span> 03 <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">--</span> -</span> 04 05 <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span

Upload: siejuelek

Post on 29-Apr-2015

456 views

Category:

Documents


8 download

DESCRIPTION

Belajar PHP

TRANSCRIPT

Page 1: Membuat Sebuah Sistem Masuk Keren Dengan PHP, MySQL & jQuery

Membuat Sebuah Sistem Masuk Keren Dengan PHP, MySQL & jQuery

Pengantar

Hari ini kita membuat suatu sistem login / pendaftaran keren & sederhana. Ini akan memberi Anda kemampuan untuk dengan mudah membuat area anggota-satunya di situs Anda dan memberikan proses pendaftaran mudah.

Hal ini akan menjadi PHP didorong dan menyimpan semua pendaftaran ke dalam database MySQL.

Untuk menambahkan bakat yang dibutuhkan, kita menggunakan menakjubkan panel jQuery geser , yang dikembangkan oleh Web-kreation .

Langkah 1 - MySQL

Pertama kita harus membuat tabel yang akan menampung semua pendaftaran. Kode ini tersedia dalam table.sql.

table.sql

01<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">--</span> -</span>

02<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">-- Table structure for table `tz_members`</span> - Tabel struktur untuk tz_members tabel `</span>

03<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">--</span> -</span>

04  

05

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">CREATE TABLE `tz_members` (</span> CREATE TABLE `tz_members` (</span>

06

  <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">`id` int(11) NOT NULL auto_increment,</span> `Id` int (11) NOT NULL AUTO_INCREMENT,</span>

07

  <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">`usr` varchar(32) collate utf8_unicode_ci NOT NULL default '',</span> `Usr` varchar (32) menyusun utf8_unicode_ci'' TIDAK NULL default,</span>

08   <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span

Page 2: Membuat Sebuah Sistem Masuk Keren Dengan PHP, MySQL & jQuery

class="google-src-text" style="direction: ltr; text-align: left">`pass` varchar(32) collate utf8_unicode_ci NOT NULL default '',</span> `Lulus` varchar (32) menyusun utf8_unicode_ci NOT NULL'' standar,</span>

09

  <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">`email` varchar(255) collate utf8_unicode_ci NOT NULL default '',</span> `Email` varchar (255) menyusun utf8_unicode_ci'' TIDAK NULL default,</span>

10

  <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">`regIP` varchar(15) collate utf8_unicode_ci NOT NULL default '',</span> `RegIP` varchar (15) menyusun utf8_unicode_ci'' TIDAK NULL default,</span>

11

  <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">`dt` datetime NOT NULL default '0000-00-00 00:00:00',</span> `Dt` datetime NOT NULL standar '0000-00-00 00:00:00 ',</span>

12

  <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">PRIMARY KEY (`id`),</span> PRIMARY KEY (`id`),</span>

13

  <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">UNIQUE KEY `usr` (`usr`)</span> UNIK KEY `usr` (`usr`)</span>

14

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;</span> ) ENGINE = MyISAM DEFAULT CHARSET = utf8 COLLATE = utf8_unicode_ci;</span>

Perhatikan bahwa kita telah mendefinisikan id sebagai integer dengan auto_increment - secara otomatis ditetapkan untuk setiap anggota situs. Juga, kami telah didefinisikan usr sebagai kunci unik - tidak ada dua pengguna dengan username yang sama diperbolehkan.

Kami kemudian menggunakan ini dalam registrasi untuk menentukan apakah username telah diambil.

Setelah Anda membuat tabel, jangan lupa untuk mengisi kredensial database Anda di connect.php sehingga Anda dapat menjalankan demo di server Anda sendiri.

Langkah 2 - XHTML

Pertama, kita harus memasukkan formulir Web-kreation ke dalam halaman kami.

demo.php

001<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><!-- Panel --></span> <- Panel -></span>

002 <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-

Page 3: Membuat Sebuah Sistem Masuk Keren Dengan PHP, MySQL & jQuery

src-text" style="direction: ltr; text-align: left"><div id="toppanel"></span> <div id="toppanel"></span>

003  

004

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><div id="panel"></span> <div id="panel"></span>

005

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><div class="content clearfix"></span> <div class="content clearfix"></span>

006

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><div class="left"></span> <div class="left"></span>

007<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><h1>The Sliding jQuery Panel</h1></span> <h1> Panel jQuery Sliding </ h1></span>

008<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><h2>A register/login solution</h2></span> <h2> Sebuah solusi mendaftar / login </ h2></span>

009

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><p class="grey">You are free to use this login and registration system in you sites!</p></span> <p class="grey"> Anda bebas untuk menggunakan sistem login dan pendaftaran di situs Anda </ p>!</span>

010<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><h2>A Big Thanks</h2></span> <h2> A Big Thanks </ h2></span>

011

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><p class="grey">This tutorial was built on top of <a href="http://web-kreation.com/index.php/tutorials/nice-clean-sliding-

login-panel-built-with-jquery" title="Go to site">Web-Kreation</a>'s amazing sliding panel.</p></span> <p class="grey"> Tutorial ini dibangun di atas <a href = "http://web-kreation.com/index.php/tutorials/nice-clean-sliding-login-panel-built-with- jquery "title =" Pergi ke situs "> Web-Kreation </ a> 's panel geser menakjubkan </ p>.</span>

012<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"></div></span> </ Div></span>

013  

014<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><?php</span> <? Php</span>

015<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">if(!$_SESSION['id']):</span> if ($ _SESSION ['id']!):</span>

016 <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-

Page 4: Membuat Sebuah Sistem Masuk Keren Dengan PHP, MySQL & jQuery

src-text" style="direction: ltr; text-align: left">// If you are not logged in</span> / / Jika Anda tidak login</span>

017<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">?></span> ?></span>

018  

019

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><div class="left"></span> <div class="left"></span>

020<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><!-- Login Form --></span> <- Login Form -></span>

021

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><form class="clearfix" action="" method="post"></span> <form class="clearfix" action="" method="post"></span>

022<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><h1>Member Login</h1></span> Login Anggota <h1> </ h1></span>

023  

024<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><?php</span> <? Php</span>

025<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">if($_SESSION['msg']['login-err'])</span> if ($ _SESSION ['msg'] ['login-err'])</span>

026<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">{</span> {</span>

027

    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">echo '<div class="err">'.$_SESSION['msg']['login-err'].'</div>';</span> echo '<div class="err">' $ _SESSION ['msg'] ['login-err'] '</ div>'..;</span>

028

    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">unset($_SESSION['msg']['login-err']);</span> unset ($ _SESSION ['msg'] ['login-err']);</span>

029

    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">// This will output login errors, if any</span> / / Ini akan menampilkan kesalahan masuk, jika ada</span>

030<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">}</span> }</span>

031<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">?></span> ?></span>

032  

033 <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><label class="grey"

Page 5: Membuat Sebuah Sistem Masuk Keren Dengan PHP, MySQL & jQuery

for="username">Username:</label></span> <label class="grey" for="username"> Username: </ label></span>

034

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><input class="field" type="text" name="username" id="username" value="" size="23" /></span> <input type="text" class="field" name="username" id="username" value="" size="23" /></span>

035

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><label class="grey" for="password">Password:</label></span> <label class="grey" for="password"> Password: </ label></span>

036

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><input class="field" type="password" name="password" id="password" size="23" /></span> <input class="field" type="password" name="password" id="password" size="23" /></span>

037

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><label><input name="rememberMe" id="rememberMe" type="checkbox" checked="checked" value="1" /> &nbsp;Remember me</label></span> <label> <input name="rememberMe" id="rememberMe" type="checkbox" checked="checked" value="1" /> Ingat saya </ label></span>

038

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><div class="clear"></div></span> <div class="clear"> </ div></span>

039

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><input type="submit" name="submit" value="Login" class="bt_login" /></span> <input type="submit" name="submit" value="Login" class="bt_login" /></span>

040<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"></form></span> </ Form></span>

041  

042<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"></div></span> </ Div></span>

043  

044

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><div class="left right"></span> <div class="left right"></span>

045  

046<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><!-- Register Form --></span> <-! Daftar Form -></span>

Page 6: Membuat Sebuah Sistem Masuk Keren Dengan PHP, MySQL & jQuery

047  

048

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><form action="" method="post"></span> <form action="" method="post"></span>

049

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><h1>Not a member yet?</span> <h1> Belum menjadi anggota?</span> <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">Sign Up!</h1></span> Sign Up! </ H1></span>

050  

051<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><?php</span> <? Php</span>

052  

053<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">if($_SESSION['msg']['reg-err'])</span> if ($ _SESSION ['msg'] ['reg-err'])</span>

054<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">{</span> {</span>

055

    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">echo '<div class="err">'.$_SESSION['msg']['reg-err'].'</div>';</span> echo '<div class="err">' $ _SESSION ['msg'] ['reg-err'] '</ div>'..;</span>

056

    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">unset($_SESSION['msg']['reg-err']);</span> unset ($ _SESSION ['msg'] ['reg-err']);</span>

057

    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">// This will output the registration errors, if any</span> / / Ini akan menampilkan kesalahan pendaftaran, jika ada</span>

058<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">}</span> }</span>

059  

060

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">if($_SESSION['msg']['reg-success'])</span> if ($ _SESSION ['msg'] ['reg-keberhasilan'])</span>

061<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">{</span> {</span>

062     <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">echo '<div class="success">'.$_SESSION['msg']['reg-success'].'</div>';</span> echo

'<div class="success">' $ _SESSION ['msg'] ['reg-keberhasilan'] '</

Page 7: Membuat Sebuah Sistem Masuk Keren Dengan PHP, MySQL & jQuery

div>'..;</span>

063

    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">unset($_SESSION['msg']['reg-success']);</span> unset ($ _SESSION ['msg'] ['reg-keberhasilan']);</span>

064

    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">// This will output the registration success message</span> / / Ini akan menampilkan pesan sukses registrasi</span>

065<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">}</span> }</span>

066  

067<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">?></span> ?></span>

068  

069

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><label class="grey" for="username">Username:</label></span> <label class="grey" for="username"> Username: </ label></span>

070

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><input class="field" type="text" name="username" id="username" value="" size="23" /></span> <input type="text" class="field" name="username" id="username" value="" size="23" /></span>

071

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><label class="grey" for="email">Email:</label></span> <label class="grey" for="email"> Email: </ label></span>

072

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><input class="field" type="text" name="email" id="email" size="23" /></span> <input type="text" class="field" name="email" id="email" size="23" /></span>

073

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><label>A password will be e-mailed to you.</label></span> <label> Sebuah kata sandi akan e-mail kepada Anda </ label>.</span>

074

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><input type="submit" name="submit" value="Register" class="bt_register" /></span> <input type="submit" name="submit" value="Register" class="bt_register" /></span>

075<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"></form></span> </ Form></span>

076  

077 <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"></div></span> </

Page 8: Membuat Sebuah Sistem Masuk Keren Dengan PHP, MySQL & jQuery

Div></span>

078  

079<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><?php</span> <? Php</span>

080<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">else:</span> lain:</span>

081<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">// If you are logged in</span> / / Jika Anda login</span>

082<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">?></span> ?></span>

083  

084

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><div class="left"></span> <div class="left"></span>

085<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><h1>Members panel</h1></span> Anggota <h1> panel </ h1></span>

086

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><p>You can put member-only data here</p></span> <p> Anda dapat menempatkan anggota-satunya data di sini </ p></span>

087

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><a href="registered.php">View a special member page</a></span>

href="registered.php"> <a Lihat halaman khusus anggota </ a></span>

088<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><p>- or -</p></span> <p> - atau - </ p></span>

089

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><a href="?logoff">Log off</a></span> <a href="?logoff"> Log off </ a></span>

090<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"></div></span> </ Div></span>

091

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><div class="left right"></span> <div class="left right"></span>

092<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"></div></span> </ Div></span>

093  

094 <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><?php</span> <?

Page 9: Membuat Sebuah Sistem Masuk Keren Dengan PHP, MySQL & jQuery

Php</span>

095<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">endif;</span> endif;</span>

096<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">// Closing the IF-ELSE construct</span> / / Menutup IF-ELSE membangun</span>

097<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">?></span> ?></span>

098  

099<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"></div></span> </ Div></span>

100<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"></div> <!-- /login --></span> </ Div> <-! / Login -></span>

101  

102<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><!-- The tab on top --></span> <- Tab di atas -!></span>

103

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><div class="tab"></span> <div class="tab"></span>

104

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><ul class="login"></span> <ul class="login"></span>

105

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><li class="left">&nbsp;</li></span> <li class="left"> </ li></span>

106

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><li>Hello <?php echo $_SESSION['usr'] ?</span> <li> Hello <? php menggemakan $ _SESSION ['usr']?</span> <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">$_SESSION['usr'] : 'Guest';?>!</li></span> $ _SESSION ['Usr']:!? 'Guest';> </ li></span>

107

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><li class="sep">|</li></span> <li class="sep"> | </ li></span>

108

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><li id="toggle"></span> <li id="toggle"></span>

109 <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><a id="open" class="open" href="#"><?php echo $_SESSION['id']?'Open Panel':'Log In | Register';?></a></span> <a id="open" class="open" href="#"> <? php echo $

Page 10: Membuat Sebuah Sistem Masuk Keren Dengan PHP, MySQL & jQuery

_SESSION ['id'] 'Panel Buka':? 'Log In | Register';?> </ a></span>

110

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><a id="close" style="display: none;" class="close" href="#">Close Panel</a></span> <a id="close" style="display: none;" class="close" href="#"> Panel Tutup </ a></span>

111<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"></li></span> </ Li></span>

112

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><li class="right">&nbsp;</li></span> <li class="right"> </ li></span>

113<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"></ul></span> </ Ul></span>

114  

115<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"></div> <!-- / top --></span> </ Div> <-! / Top -></span>

116<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"></div> <!--panel --></span> </ Div> <-! Panel -></span>

Pada beberapa tempat di kode ini, ada beberapa operator PHP yang memeriksa apakah $ _SESSION ['usr'] atau $ _SESSION ['id'] didefinisikan. Hal ini berlaku hanya jika pengunjung halaman login di situs, yang memungkinkan kita untuk menampilkan konten khusus untuk anggota situs. Kami akan mencakup secara rinci dalam sekejap.

Setelah formulir, kami menempatkan sisa halaman.

01

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><div class="pageContent"></span> <div class="pageContent"></span>

02  

03

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><div id="main"></span> <div id="main"></span>

04  

05

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><div class="container"></span> <div class="container"></span>

06<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><h1>A Cool Login System</h1></span> <h1> Sebuah Sistem Masuk Keren </ h1></span>

07 <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-

Page 11: Membuat Sebuah Sistem Masuk Keren Dengan PHP, MySQL & jQuery

src-text" style="direction: ltr; text-align: left"><h2>Easy registration management with PHP &amp; jQuery</h2></span> <h2> manajemen pendaftaran Mudah dengan PHP & jQuery </ h2></span>

08<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"></div></span> </ Div></span>

09  

10

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><div class="container"></span> <div class="container"></span>

11<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><p>This is a ...</p></span> <p> ini adalah ... </ p></span>

12

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><div class="clear"></div></span> <div class="clear"> </ div></span>

13  

14<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"></div></span> </ Div></span>

15  

16<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"></div></span> </ Div></span>

Tidak ada yang istimewa di sini. Mari kita lanjutkan dengan backend PHP.

Sistem login

Langkah 3 - PHP

Page 12: Membuat Sebuah Sistem Masuk Keren Dengan PHP, MySQL & jQuery

Ini adalah waktu untuk mengubah bentuk menjadi sebuah pendaftaran lengkap dan sistem login. Untuk mencapai itu, kita akan membutuhkan lebih dari jumlah biasa PHP. Saya akan membagi kode menjadi dua bagian.

Jika Anda berencana untuk menambahkan lebih banyak kode, itu akan menjadi ide yang baik untuk membagi ke dalam beberapa file yang disertakan saat diperlukan. Ini membantu pengembangan proyek-proyek besar dan memungkinkan penggunaan kembali kode di bagian yang berbeda dari situs.

Tapi mari kita lihat bagaimana kita melakukannya di sini.

demo.php

01

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">define('INCLUDE_CHECK',true);</span> define ('INCLUDE_CHECK', true);</span>

02  

03

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">require 'connect.php';</span> require 'connect.php';</span>

04<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">require 'functions.php';</span> membutuhkan 'functions.php';</span>

05  

06

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">// Those two files can be included only if INCLUDE_CHECK is defined</span> / / Kedua file dapat dimasukkan hanya jika INCLUDE_CHECK didefinisikan</span>

07  

08<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">session_name('tzLogin');</span> session_name ('tzLogin');</span>

09<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">// Starting the session</span> / / Mulai sesi</span>

10  

11

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">session_set_cookie_params(2*7*24*60*60);</span> session_set_cookie_params (2 * 7 * 24 * 60 * 60);</span>

12<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">// Making the cookie live for 2 weeks</span> / / Membuat cookie hidup selama 2 minggu</span>

Page 13: Membuat Sebuah Sistem Masuk Keren Dengan PHP, MySQL & jQuery

13  

14<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">session_start();</span> session_start ();</span>

15  

16

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">if($_SESSION['id'] && !isset($_COOKIE['tzRemember']) && !$_SESSION['rememberMe'])</span> if ($ _SESSION ['id'] && isset ($ _COOKIE ['tzRemember'])! && $ _SESSION! ['rememberMe'])</span>

17<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">{</span> {</span>

18

    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">// If you are logged in, but you don't have the tzRemember cookie (browser restart)</span> / / Jika Anda login, tetapi Anda tidak memiliki cookie tzRemember (browser restart)</span>

19

    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">// and you have not checked the rememberMe checkbox:</span> / / Dan Anda belum memeriksa kotak centang rememberMe:</span>

20  

21    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">$_SESSION = array();</span> $ _SESSION = Array ();</span>

22    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">session_destroy();</span> session_destroy ();</span>

23  

24    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">// Destroy the session</span> / / Hancurkan sesi</span>

25<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">}</span> }</span>

26  

27

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">if(isset($_GET['logoff']))</span> if (isset ($ _GET ['logoff']))</span>

28<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">{</span> {</span>

29    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">$_SESSION = array();</span> $ _SESSION = Array ();</span>

30     <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span

Page 14: Membuat Sebuah Sistem Masuk Keren Dengan PHP, MySQL & jQuery

class="google-src-text" style="direction: ltr; text-align: left">session_destroy();</span> session_destroy ();</span>

31

    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">header("Location: demo.php");</span> header ("Location: demo.php");</span>

32    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">exit;</span> exit;</span>

33<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">}</span> }</span>

34  

35

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">if($_POST['submit']=='Login')</span> if ($ _POST ['submit'] == 'Login')</span>

36<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">{</span> {</span>

37

    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">// Checking whether the Login form has been submitted</span> / / Memeriksa apakah bentuk Masuk telah disampaikan</span>

38  

39

    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">$err = array();</span> $ Err = array ();</span>

40    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">// Will hold our errors</span> / / Akan terus kesalahan kami</span>

41  

42

    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">if(!$_POST['username'] || !$_POST['password'])</span> if ($ _POST ['username'] |! |! $ _POST ['password'])</span>

43

        <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">$err[] = 'All the fields must be filled in!';</span> $ Err [] = 'Semua bidang harus diisi!';</span>

44  

45

    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">if(!count($err))</span> if (count ($ err)!)</span>

46    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">{</span> {</span>

Page 15: Membuat Sebuah Sistem Masuk Keren Dengan PHP, MySQL & jQuery

47

        <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">$_POST['username'] = mysql_real_escape_string($_POST['username']);</span> $ _POST ['Username'] = mysql_real_escape_string ($ _POST ['username']);</span>

48

        <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">$_POST['password'] = mysql_real_escape_string($_POST['password']);</span> $ _POST ['Password'] = mysql_real_escape_string ($ _POST ['password']);</span>

49

        <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">$_POST['rememberMe'] = (int)$_POST['rememberMe'];</span> $ _POST ['RememberMe'] = (int) $ _POST ['rememberMe'];</span>

50  

51        <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">// Escaping all input data</span> / / Escaping semua data input</span>

52  

53

        <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">$row = mysql_fetch_assoc(mysql_query("SELECT id,usr FROM tz_members WHERE usr='{$_POST['username']}' AND pass='".md5($_POST['password'])."'"));</span> $ Row = mysql_fetch_assoc (mysql_query ("SELECT id, usr DARI MANA tz_members usr = '{$ _POST ['

username ']}' AND pass = '" [password']). Md5 ($ _POST. '"'")) ;</span>

54  

55

        <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">if($row['usr'])</span> if ($ row ['usr'])</span>

56        <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">{</span> {</span>

57            <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">// If everything is OK login</span> / / Jika semuanya OK masuk</span>

58  

59

            <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">$_SESSION['usr']=$row['usr'];</span> $ _SESSION ['Usr'] = $ row ['usr'];</span>

60

            <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">$_SESSION['id'] = $row['id'];</span> $ _SESSION ['Id'] = $ row ['id'];</span>

61             <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span

Page 16: Membuat Sebuah Sistem Masuk Keren Dengan PHP, MySQL & jQuery

class="google-src-text" style="direction: ltr; text-align: left">$_SESSION['rememberMe'] = $_POST['rememberMe'];</span> $ _SESSION ['RememberMe'] = $ _POST ['rememberMe'];</span>

62  

63

            <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">// Store some data in the session</span> / / Menyimpan beberapa data dalam sesi</span>

64  

65

            <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">setcookie('tzRemember',$_POST['rememberMe']);</span> setcookie ('tzRemember', $ _POST ['rememberMe']);</span>

66

            <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">// We create the tzRemember cookie</span> / / Kami menciptakan cookie tzRemember</span>

67        <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">}</span> }</span>

68

        <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">else $err[]='Wrong username and/or password!';</span> lain $ err [] = 'Username salah dan / atau password!';</span>

69    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">}</span> }</span>

70  

71

    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">if($err)</span> if ($ err)</span>

72

        <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">$_SESSION['msg']['login-err'] = implode('<br />',$err);</span> $ _SESSION ['Msg'] ['login-err'] = implode ('<br />', $ err);</span>

73

        <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">// Save the error messages in the session</span> / / Simpan pesan kesalahan dalam sesi</span>

74  

75

    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">header("Location: demo.php");</span> header ("Location: demo.php");</span>

76     <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align:

Page 17: Membuat Sebuah Sistem Masuk Keren Dengan PHP, MySQL & jQuery

left">exit;</span> exit;</span>

77<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">}</span> }</span>

Berikut cookie tzRemember bertindak sebagai kontrol apakah kita harus log-off pengguna yang belum menandai "ingat saya" kotak centang. Jika cookie tidak hadir (karena me-restart browser) dan pengunjung belum memeriksa ingat saya pilihan, kita menghancurkan sesi.

Sesi itu sendiri tetap hidup selama dua minggu (seperti yang ditetapkan oleh session_set_cookie_params).

Mari kita lihat bagian kedua dari demo.php.

01

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">else if($_POST['submit']=='Register')</span> else if ($ _POST ['submit'] == 'Register')</span>

02<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">{</span> {</span>

03

    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">// If the Register form has been submitted</span> / / Jika bentuk Register telah disampaikan</span>

04

    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">$err = array();</span> $ Err = array ();</span>

05  

06

    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">if(strlen($_POST['username'])<4 ||

strlen($_POST['username'])>32)</span> if (strlen ($ _POST ['username']) <4 | | strlen ($ _POST ['username'])> 32)</span>

07    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">{</span> {</span>

08

        <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">$err[]='Your username must be between 3 and 32 characters!';</span> $ Err [] = 'Nama pengguna harus antara 3 dan 32 karakter!';</span>

09    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">}</span> }</span>

10  

11     <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">if(preg_match('/[^a-z0-9\-\_\.]+/i',$_POST['username']))</span> if

Page 18: Membuat Sebuah Sistem Masuk Keren Dengan PHP, MySQL & jQuery

(preg_match ('/ [^ a-z0-9 \ -. \ _ \] + / i', $ _POST ['username']))</span>

12    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">{</span> {</span>

13

        <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">$err[]='Your username contains invalid characters!';</span> $ Err [] = 'Nama pengguna mengandung karakter yang tidak valid!';</span>

14    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">}</span> }</span>

15  

16

    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">if(!checkEmail($_POST['email']))</span> if (checkEmail ($ _POST ['email'])!)</span>

17    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">{</span> {</span>

18

        <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">$err[]='Your email is not valid!';</span> $ Err [] = 'Email Anda tidak valid!';</span>

19    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">}</span> }</span>

20  

21

    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">if(!count($err))</span> if (count ($ err)!)</span>

22    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">{</span> {</span>

23        <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">// If there are no errors</span> / / Jika tidak ada kesalahan</span>

24

        <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">$pass = substr(md5($_SERVER['REMOTE_ADDR'].microtime().rand(1,100000)),0,6);</span>

$ Lulus = substr (md5 ($ _SERVER ['REMOTE_ADDR'] microtime () rand (1,100000)), 0,6..);</span>

25        <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">// Generate a random password</span> / / Menghasilkan password acak</span>

26  

27         <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align:

Page 19: Membuat Sebuah Sistem Masuk Keren Dengan PHP, MySQL & jQuery

left">$_POST['email'] = mysql_real_escape_string($_POST['email']);</span> $ _POST ['Email'] = mysql_real_escape_string ($ _POST ['email']);</span>

28

        <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">$_POST['username'] = mysql_real_escape_string($_POST['username']);</span> $ _POST ['Username'] = mysql_real_escape_string ($ _POST ['username']);</span>

29        <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">// Escape the input data</span> / / Melarikan diri input data</span>

30  

31

        <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">mysql_query(" INSERT INTO tz_members(usr,pass,email,regIP,dt)</span> mysql_query ("INSERT INTO tz_members (usr, lulus, email, regIP, dt)</span>

32                    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">VALUES(</span> VALUES (</span>

33

                    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">'".$_POST['username']."',</span> '". $ _POST [' Username ']."',</span>

34                    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">'".md5($pass)."',</span> '"Md5 ($ pass).."',</span>

35

                    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">'".$_POST['email']."',</span> '". $ _POST [' Email ']."',</span>

36

                    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">'".$_SERVER['REMOTE_ADDR']."',</span> '". $ _SERVER [' REMOTE_ADDR ']."',</span>

37                    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">NOW()</span> SEKARANG ()</span>

38        <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">)");</span> ) ");</span>

39  

40

        <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">if(mysql_affected_rows($link)==1)</span> if (mysql_affected_rows ($ link) == 1)</span>

41        <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">{</span> {</span>

42             <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span

Page 20: Membuat Sebuah Sistem Masuk Keren Dengan PHP, MySQL & jQuery

class="google-src-text" style="direction: ltr; text-align: left">send_mail( '[email protected]',</span> send_mail ('[email protected]',</span>

43                    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">$_POST['email'],</span> $ _POST ['Email'],</span>

44

                    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">'Registration System Demo - Your New Password',</span> 'Sistem Registrasi Demo - New Password Anda,</span>

45

                    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">'Your password is: '.$pass);</span> 'Password anda

adalah:' $ pass);.</span>

46

                    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">$_SESSION['msg']['reg-success']='We sent you an email with your new password!';</span> $ _SESSION ['Msg'] ['reg-keberhasilan'] = 'Kami mengirimkan email dengan password baru Anda!';</span>

47        <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">}</span> }</span>

48

        <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">else $err[]='This username is already taken!';</span> lain $ err [] = 'Nama pengguna ini sudah diambil!';</span>

49    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">}</span> }</span>

50  

51

    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">if(count($err))</span> if (count ($ err))</span>

52    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">{</span> {</span>

53

        <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">$_SESSION['msg']['reg-err'] = implode('<br />',$err);</span> $ _SESSION ['Msg'] ['reg-err'] = implode ('<br />', $ err);</span>

54    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">}</span> }</span>

55  

56

    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">header("Location: demo.php");</span> header ("Location: demo.php");</span>

Page 21: Membuat Sebuah Sistem Masuk Keren Dengan PHP, MySQL & jQuery

57    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">exit;</span> exit;</span>

58<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">}</span> }</span>

59  

60<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">$script = '';</span> $ Script ='';</span>

61

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">if($_SESSION['msg'])</span> if ($ _SESSION ['msg'])</span>

62<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">{</span> {</span>

63

    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">// The script below shows the sliding panel on page load</span> / / Script di bawah ini menunjukkan panel geser pada buka halaman</span>

64    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">$script = '</span> $ Script = '</span>

65    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><script type="text/javascript"></span> <script type="text/javascript"></span>

66    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">$(function(){</span> $ (Function () {</span>

67        <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">$("div#panel").show();</span> . $ ("Div # panel") menunjukkan ();</span>

68        <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">$("#toggle a").toggle();</span> . $ ("# Beralih a") beralih ();</span>

69    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">});</span> });</span>

70    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"></script>';</span> </ Script> ';</span>

71<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">}</span> }</span>

Kami menyimpan semua kesalahan yang ditemui dalam sebuah array $ err, yang kemudian diberikan ke sebuah variabel $ _SESSION. Hal ini memungkinkan untuk dapat diakses setelah browser redirect.

Page 22: Membuat Sebuah Sistem Masuk Keren Dengan PHP, MySQL & jQuery

Anda mungkin telah melihat di beberapa situs, bahwa ketika Anda menyerahkan formulir dan kemudian refresh halaman, data dikirim seluruh lagi. Ini bisa menjadi masalah karena bisa menyebabkan pendaftaran ganda dan beban server yang tidak perlu.

Kami menggunakan fungsi header untuk mencegah hal ini, dengan mengarahkan browser ke halaman yang sama. Ini dimulai pandangan segar halaman, tanpa browser menghubungkannya dengan formulir kirimkan. Hasilnya adalah bahwa, pada refresh halaman, tidak ada data yang dikirim.

Tapi seperti kita menggunakan $ _SESSION untuk menyimpan semua kesalahan ditemui adalah penting bahwa kita tidak diset variabel-variabel ini, setelah kami menunjukkan kesalahan kepada pengguna. Jika tidak, mereka akan ditampilkan pada setiap tampilan halaman (garis disorot pada bagian XHTML dari tutorial).

Juga perhatikan bagaimana kita membuat sendiri skrip tambahan (baris 60-70 dari bagian kedua dari kode PHP) yang menunjukkan panel di buka halaman, sehingga pesan-pesan yang terlihat oleh pengguna.

Sekarang mari kita lihat di CSS.

Page 23: Membuat Sebuah Sistem Masuk Keren Dengan PHP, MySQL & jQuery

Sistem registrasi / login

Langkah 4 - CSS

Panel geser datang dengan style sheet sendiri. Ini berarti kita hanya tersisa menciptakan gaya halaman.

demo.css

01

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">body,h1,h2,h3,p,quote,small,form,input,ul,li,ol,label{</span> tubuh, h1, h2, h3, p, kutipan, kecil, bentuk, masukan, ul, li, ol, label {</span>

02    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">/* The reset rules */</span> / * Aturan ulang * /</span>

03    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">margin:0px;</span> margin: 0px;</span>

04    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">padding:0px;</span> padding: 0px;</span>

05<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">}</span> }</span>

06  

07<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">body{</span> body {</span>

08    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">color:#555555;</span> color: # 555555;</span>

09    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">font-size:13px;</span> font-size: 13px;</span>

10    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">background: #eeeeee;</span> background: # eeeeee;</span>

11

    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">font-family:Arial, Helvetica, sans-serif;</span> font-family: Arial, Helvetica, sans-serif;</span>

12    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">width: 100%;</span> width: 100%;</span>

13<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">}</span> }</span>

14  

Page 24: Membuat Sebuah Sistem Masuk Keren Dengan PHP, MySQL & jQuery

15<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">h1{</span> h1 {</span>

16    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">font-size:28px;</span> font-size: 28px;</span>

17    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">font-weight:bold;</span> font-weight: bold;</span>

18

    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">font-family:"Trebuchet MS",Arial, Helvetica, sans-serif;</span> font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;</span>

19    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">letter-spacing:1px;</span> letter-spacing: 1px;</span>

20<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">}</span> }</span>

21  

22<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">h2{</span> h2 {</span>

23

    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">font-family:"Arial Narrow",Arial,Helvetica,sans-serif;</span> font-family: "Arial Narrow", Arial, Helvetica, sans-serif;</span>

24    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">font-size:10px;</span> font-size: 10px;</span>

25    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">font-weight:normal;</span> font-weight: normal;</span>

26    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">letter-spacing:1px;</span> letter-spacing: 1px;</span>

27    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">padding-left:2px;</span> padding-left: 2px;</span>

28    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">text-transform:uppercase;</span> text-transform: uppercase;</span>

29    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">white-space:nowrap;</span> white-space: nowrap;</span>

30    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">margin-top:4px;</span> margin-top: 4px;</span>

31    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">color:#888888;</span> color: # 888888;</span>

32 <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-

Page 25: Membuat Sebuah Sistem Masuk Keren Dengan PHP, MySQL & jQuery

src-text" style="direction: ltr; text-align: left">}</span> }</span>

33  

34<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">#main p{</span> # Main p {</span>

35    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">padding-bottom:8px;</span> padding-bottom: 8px;</span>

36<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">}</span> }</span>

37  

38<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">.clear{</span> . Jelas {</span>

39    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">clear:both;</span> clear: both;</span>

40<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">}</span> }</span>

41  

42<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">#main{</span> # Main {</span>

43    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">width:800px;</span> width: 800px;</span>

44

    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">/* Centering it in the middle of the page */</span> / * Centering itu di tengah-tengah halaman * /</span>

45

    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">margin:60px auto;</span> margin: 60px auto;</span>

46<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">}</span> }</span>

47  

48<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">.container{</span> . Kontainer {</span>

49    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">margin-top:20px;</span> margin-top: 20px;</span>

50  

51     <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span

Page 26: Membuat Sebuah Sistem Masuk Keren Dengan PHP, MySQL & jQuery

class="google-src-text" style="direction: ltr; text-align: left">background:#FFFFFF;</span> background: # FFFFFF;</span>

52

    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">border:1px solid #E0E0E0;</span> border: 1px solid # E0E0E0;</span>

53    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">padding:15px;</span> padding: 15px;</span>

54  

55    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">/* Rounded corners */</span> / * Rounded sudut * /</span>

56    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">-moz-border-radius:20px;</span> -Moz-border-radius: 20px;</span>

57    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">-khtml-border-radius: 20px;</span> -KHTML-border-radius: 20px;</span>

58    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">-webkit-border-radius: 20px;</span> -Webkit-border-radius: 20px;</span>

59    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">border-radius:20px;</span> border-radius: 20px;</span>

60<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">}</span> }</span>

61  

62<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">.err{</span> . Err {</span>

63    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">color:red;</span> warna: merah;</span>

64<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">}</span> }</span>

65  

66<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">.success{</span> . Sukses {</span>

67    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">color:#00CC00;</span> color: # 00CC00;</span>

68<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">}</span> }</span>

69  

Page 27: Membuat Sebuah Sistem Masuk Keren Dengan PHP, MySQL & jQuery

70<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">a, a:visited {</span> a, a: visited {</span>

71    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">color:#00BBFF;</span> color: # 00BBFF;</span>

72    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">text-decoration:none;</span> text-decoration: none;</span>

73    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">outline:none;</span> outline: none;</span>

74<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">}</span> }</span>

75  

76<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">a:hover{</span> a: hover {</span>

77    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">text-decoration:underline;</span> text-decoration: underline;</span>

78<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">}</span> }</span>

79  

80<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">.tutorial-info{</span> . Tutorial-info {</span>

81    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">text-align:center;</span> text-align: center;</span>

82    <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">padding:10px;</span> padding: 10px;</span>

83<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left">}</span> }</span>

Langkah 5 - jQuery

Panel geser dilengkapi dengan file sendiri jQuery.

demo.php

01 <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></

script></span> <script type="text/javascript"

Page 28: Membuat Sebuah Sistem Masuk Keren Dengan PHP, MySQL & jQuery

src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"> </ script></span>

02  

03<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><!-- PNG FIX for IE6 --></span> <-! PNG FIX untuk IE6 -></span>

04

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><!-- http://24ways.org/2007/supersleight-transparent-png-in-ie6 --></span> <- Http://24ways.org/2007/supersleight-transparent-png-in-ie6 -!></span>

05<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><!--[if lte IE 6]></span> <-! [Jika lte IE 6]></span>

06

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><script type="text/javascript" src="login_panel/js/pngfix/supersleight-min.js"></script></span> <script type="text/javascript" src="login_panel/js/pngfix/supersleight-min.js"> </ script></span>

07<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><![endif]--></span> <[Endif] -></span>

08  

09

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><script src="login_panel/js/slide.js" type="text/javascript"></script></span> <script src="login_panel/js/slide.js" type="text/javascript"> </ script></span>

10  

11

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left"><?php echo $script; ?></span> <? Php echo $ naskah;?></span>

Pertama kita termasuk perpustakaan jQuery dari CDN Google. Kemudian datang memperbaiki khusus untuk isu-isu transparansi IE6 PNG dan terakhir script panel disertakan.

Di bagian bawah halaman adalah variabel skrip $ - itu menunjukkan panel di buka halaman jika diperlukan.

Dengan sistem ini keren kami masuk selesai!

Kesimpulan

Hari ini kita belajar bagaimana menggunakan komponen bentuk fantastis dan mengubahnya menjadi sebuah log fungsional dalam sistem / pendaftaran.

Page 29: Membuat Sebuah Sistem Masuk Keren Dengan PHP, MySQL & jQuery

Anda bebas untuk dibangun di atas kode ini dan memodifikasi cara apapun yang Anda lihat cocok.