sebagai contoh dengan nama dblatihan
kemudian buat table dengan nama tbl_auth_user
dengan field user_id(varchar), user_password(varchar).
setelah database terbentuk buat file conect.php dengan script sbb :
$koneksi=mysql_connect("localhost","root",""); mysql_select_db("dblatihan"); |
kemudian buat file untuk create number nya. dengan script berikut simpan dengan nama file createnumber.php
<?php session_start(); //
generate 4 digit random number // create
the hash for the random number and put it in the session // create
the image // use white
as the background image // the text
color is black // write
the random number // send several
headers to make sure the image is not cached // Date in
the past // always
modified // HTTP/1.1
// HTTP/1.0
// send the
content type header so the image is displayed properly // send the
image to the browser // destroy
the image to free up the memory |
Kemudian buat file loginnya, dengan script berikut dan simpan dengan nama file flogin.php
<?php // we must never forget to start the session session_start(); $errorMessage
= ''; if (md5($number)
== $_SESSION['image_random_value']) { $result = mysql_query($sql)
or if (mysql_num_rows($result)
== 1) { // remove the random
value from session // after login we
move to the main page } else { <body> <tr> |
kemudian satu lagi, buat file sebagai header ketika login & verification code sukses dilakukan, simpan dengan nama main.php
<html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body text="#FF0000"> <div align="center"> <p> </p> <p> </p> <p><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Connection Sucess... </strong></font></p> <p> </p> <p><strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Selamet ya Bro...</font></strong></p> <p> </p> <p><strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><a href="flogin.php">Back</a></font></strong></p> </div> </body> </html> |
kemudian jalankan di browser, jangan lupa aktifkan webserver anda.
Selamat Mencoba.. :)