Jump to content
Sign in to follow this  
bundlebook2u

Simple Login Php (source Code)

Recommended Posts

[size=4]Bagaimana membuat simple login.[/size]
[size=4][url="http://www.phpeasystep.com/imgs/member_login.gif"][img]http://www.phpeasystep.com/imgs/member_login.gif[/img][/url][/size]
[url="http://bundlebook2u.blogspot.com/2011/11/simple-login-php.html"][size=4]SILA DOWNLOAD SOURCE CODE DISINI BERSAMA DATABASE MySQL [/size][/url]

Share this post


Link to post
Share on other sites
Yang style bro rasanya kat website image bro ada kan : [url="http://www.phpeasystep.com/phptu/6.html"]Simple Login [/url]

WP & Joomla Style nih.

Step 1 - create a table dbUsers with the scripts below:
[spoiler]
CREATE TABLE dbUsers(
id int NOT NULL AUTO_INCREMENT,
username varchar(16),
password char(16),
email varchar(25),
PRIMARY KEY(id),
UNIQUE (username)
)[/spoiler]

Step 2 - create a file dbConfig.php with the codes below:
[spoiler]<?
// Replace the variable values below
// with your specific database information.
$host = "localhost";
$user = "UserName";
$pass = "Password";
$db = "dbName";

// This part sets up the connection to the
// database (so you don't need to reopen the connection
// again on the same page).
$ms = mysql_pconnect($host, $user, $pass);
if ( !$ms )
{
echo "Error connecting to database.\n";
}

// Then you need to make sure the database you want
// is selected.
mysql_select_db($db);
?>[/spoiler]


Step 3 - create a file register.php with the codes below:
[spoiler]
<?php

// dbConfig.php is a file that contains your
// database connection information. This
// tutorial assumes a connection is made from
// this existing file.
include ("dbConfig.php");


//Input vaildation and the dbase code
if ( $_GET["op"] == "reg" )
{
$bInputFlag = false;
foreach ( $_POST as $field )
{
if ($field == "")
{
$bInputFlag = false;
}
else
{
$bInputFlag = true;
}
}
// If we had problems with the input, exit with error
if ($bInputFlag == false)
{
die( "Problem with your registration info. "
."Please go back and try again.");
}

// Fields are clear, add user to database
// Setup query
$q = "INSERT INTO `dbUsers` (`username`,`password`,`email`) "
."VALUES ('".$_POST["username"]."', "
."PASSWORD('".$_POST["password"]."'), "
."'".$_POST["email"]."')";
// Run query
$r = mysql_query($q);

// Make sure query inserted user successfully
if ( !mysql_insert_id() )
{
die("Error: User not added to database.");
}
else
{
// Redirect to thank you page.
Header("Location: register.php?op=thanks");
}
} // end if


//The thank you page
elseif ( $_GET["op"] == "thanks" )
{
echo "<h2>Thanks for registering!</h2>";
}

//The web form for input ability
else
{
echo "<form action=\"?op=reg\" method=\"POST\">\n";
echo "Username: <input name=\"username\" MAXLENGTH=\"16\"><br />\n";
echo "Password: <input type=\"password\" name=\"password\" MAXLENGTH=\"16\"><br />\n";
echo "Email Address: <input name=\"email\" MAXLENGTH=\"25\"><br />\n";
echo "<input type=\"submit\">\n";
echo "</form>\n";
}
// EOF
?>[/spoiler]

Step 4 - create a file login.php with the codes below:
[spoiler]
<?php
session_start();
// dBase file
include "dbConfig.php";

if ($_GET["op"] == "login")
{
if (!$_POST["username"] || !$_POST["password"])
{
die("You need to provide a username and password.");
}

// Create query
$q = "SELECT * FROM `dbUsers` "
."WHERE `username`='".$_POST["username"]."' "
."AND `password`=PASSWORD('".$_POST["password"]."') "
."LIMIT 1";
// Run query
$r = mysql_query($q);

if ( $obj = @mysql_fetch_object($r) )
{
// Login good, create session variables
$_SESSION["valid_id"] = $obj->id;
$_SESSION["valid_user"] = $_POST["username"];
$_SESSION["valid_time"] = time();

// Redirect to member page
Header("Location: members.php");
}
else
{
// Login not successful
die("Sorry, could not log you in. Wrong login information.");
}
}
else
{
//If all went right the Web form appears and users can log in
echo "<form action=\"?op=login\" method=\"POST\">";
echo "Username: <input name=\"username\" size=\"15\"><br />";
echo "Password: <input type=\"password\" name=\"password\" size=\"8\"><br />";
echo "<input type=\"submit\" value=\"Login\">";
echo "</form>";
}
?>[/spoiler]


Step 5 - create a file members.php with the codes below:
[spoiler]
<?php
session_start();

if (!$_SESSION["valid_user"])
{
// User not logged in, redirect to login page
Header("Location: login.php");
}

// Member only content
// ...
// ...
// ...

// Display Member information
echo "<p>User ID: " . $_SESSION["valid_id"];
echo "<p>Username: " . $_SESSION["valid_user"];
echo "<p>Logged in: " . date("m/d/Y", $_SESSION["valid_time"]);

// Display logout link
echo "<p><a href=\"logout.php\">Click here to logout!</a></p>";
?>[/spoiler]


Step 6 - create a file logout.php with the codes below:
[spoiler]
<?php
session_start();
session_unset();

session_destroy();
// Logged out, return home.
Header("Location: index.php");
?>[/spoiler] Edited by carnine9

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Similar Content

    • By puja
      Assalamualaikum korang yg baik hati..
      boleh ke bagi cth koding kelendar.. tarikh sewaan dari hingga ke hingga
      tq
    • By artacia
      ★★★ Perkhidmatan Upah Buat Sistem PHP ★★★
       
      Final Projek Pelajar (FYP): Upah RM500 keatas (RM65 setiap tambahan / pengubahsuaian)
       
      TIDAK MENERIMA TEMPAHAN SISTEM UTK SYARIKAT/SEKOLAH ATAU BADAN BERKANUN.HARAP MAKLUM
      *Harga boleh berubah bergantung kepada pengubahsuaian yang dikehendaki oleh pelanggan.
       
      ★★★ Terma dan Syarat★★★

      Deposit 50% dari harga yang ditetapkan.
      Individu yang bermasalah, akan diban serta merta daripada urusan seterusnya.
      Bayaran pendahuluan tidak akan dipulangkan kembali jika anda membatalkan setelah proses dibuat
       
      Beli sistem yang dah siap:RM200.00 / sistem
      1. Sistem Aduan Kerosakan -(eMaintenance) -http://upahbuatsistemphp.com/emaintenance
      2. Sistem Kedai Online-Jual Baju/Pizza -http://upahbuatsistemphp.com/ekedai
      3. Sistem Permohonan Tempahan Peralatan ICT dan Bilik -http://upahbuatsistemphp.com/ePeralatan
      4. Sistem Keluar Masuk-Punch In
      5. Sistem Paparan Kehadiran Pensyarah -http://upahbuatsistemphp.com/epaparan
      6. Sistem e-Museum -http://upahbuatsistemphp.com/emuseum
      7.Sistem Permohonan Cuti-e-Cuti -http://upahbuatsistemphp.com/cslms
      8. Sistem Permohonan Lesen Penjaja -http://upahbuatsistemphp.com/eLesen
      9. Sistem Pinjaman Buku (e-Library) -http://upahbuatsistemphp.com/elibrary
      10. Sistem Kehadiran Kelas Pelajar (e-Kedatangan) -http://upahbuatsistemphp.com/eAttendance
      11. Sistem Klinik (eKlinik) -http://upahbuatsistemphp.com/clinic
      12. Sistem Inventori (Jual dan Bekal) (e-Inventori) -http://upahbuatsistemphp.com/einventori
      13. Sistem Kutipan Yuran Ahli Kelab (e-Yuran) -http://upahbuatsistemphp.com/eakaun
      14. Sistem Claim Kos Perubatan Kakitangan (eMedicalcit) -http://upahbuatsistemphp.com/medicalcit
      15. Sistem Maklumat Ukuran Jahitan (eJahit) -http://upahbuatsistemphp.com/ejahit
      16. Sistem Rekod Keluar Masuk Surat (eSurat) -http://upahbuatsistemphp.com/esurat
      17. Sistem Login Kehadiran Kakitangan (e-Login) -http://upahbuatsistemphp.com/elogin
      18. Sistem/Portal Perkongsian Maklumat (e-Learn) -http://upahbuatsistemphp.com/elearn
      19. Sistem Iklan Tanah & Rumah (e-Iklan) -http://upahbuatsistemphp.com/eiklan
      20. Sistem Pengurusan Pusat Tuisyen (e-Tuisyen) - http://upahbuatsistemphp.com/etuisyen
      21. Sistem Tempahan Asrama (e-Asrama) -http://upahbuatsistemphp.com/easrama
      22. Sistem Carian Fail (e-fail) -http://upahbuatsistemphp.com/afiss
      23. Sistem Kehadiran Kakitangan PDRM (epdrm) -http://upahbuatsistemphp.com/epdrm
      24. Sistem Permohonan Lawatan (eUKK) -http://upahbuatsistemphp.com/eUKK
      25. Sistem Permohonan Tajuk Projek FYP (eFYP) -http://upahbuatsistemphp.com/efyp
      26. Sistem Pengurusan Barangan Pos (eParcel) -http://upahbuatsistemphp.com/eparcel
      27. Sistem Booking Hotel (eHotel) -http://upahbuatsistemphp.com/ehotel
      28. Sistem E-Warden (eWarden) -http://upahbuatsistemphp.com/warden
      29. Sistem Pengurusan Aduan- (eComplaint) -http://upahbuatsistemphp.com/ecomplaint/
      30. Sistem Tempahan Bilik Mesyuarat -(e-Bilik) -http://upahbuatsistemphp.com/ebilik
      31. Sistem Keluar Masuk Kolej (eouting) -http://upahbuatsistemphp.com/eouting
      32. Badminton Court Booking System -http://upahbuatsistemphp.com/esport/
      33. Car Rental System v2.0 Pro -http://upahbuatsistemphp.com/crental
      34. Shopping Cart Kedai Emas -http://upahbuatsistemphp.com/lo
      35. Sistem Kedatangan Pelajar Kolej (eHadir) -http://upahbuatsistemphp.com/ehadir
      36. Sistem Permohonan Kerja (eJobs) -http://upahbuatsistemphp.com/jobs
       
      Beli ebook belajar php mysql:RM30.00
      Borang pembelian:http://upahbuatsistemphp.com/ebook/
       
      No.Telefon:013-3034626/Sms/Whatsapp (Arif)
       
    • By malikperangcic
      Salam. Saya ada conduct training untuk CakePHP ,jadi saya hendak menjual modul Asas CakePHP MVC ini untuk sesiapa yang nak membangunkan sebuah aplikasi dalam masa yang singkat.

      Modul ini mempunyai 40 page ke atas.
      Boleh baca isi kandungan dekat description dahulu .

      Anda boleh dapatkan modul Asas CakePHP MVC disini,

      -> Asas CakePHP MVC
       
      Benefit dari modul ini adalah ,anda dapat belajar membina prototaip projek aplikasi web dalam masa yang singkat. Kalau saya punya benchmark 5 minit.
       
      Jika anda mempunyai sebarang masalah,boleh hubungi saya di malikperang[at]gmail.com.

      Sekian. Terima kasih.
    • By malikperangcic
      Salam otai putera.com semua.
       
      Nak tanya,adakah recommendation engine ni adakah salah satu ciri big data? sebab terbaca yang ni. 
       
      link : http://www.forbes.com/sites/lutzfinger/2014/09/02/recommendation-engines-the-reason-why-we-love-big-data/
       
      lepas tu google lagi,jumpa dekat stackoverflow diorang suruh baca "Programming Collective Intelligence" by O'Reilly.
       
      link : http://stackoverflow.com/questions/1407841/how-to-create-my-own-recommendation-engine
       
      ada warga putera.com yang pernah buat recommendation engine ni guna PHP?
       
      boleh share pengalaman anda seperti dari segi ,
       
      Algorithm & Solution,
      Database design.
       
      ada task client dia nak recommendation engine macam amazon.com dekat bawah product ada paparan
       
      "Customers Who Bought This Item Also Bought" 
       
      Just nak cari idea sementara baca buku Programming Collective Intelligence ,jika ada harap boleh berkongsi.  Thanks !
       
    • By razirazo
      Salam putera. Nak bagi job ni. Yang boleh write PHP; tak kisahla freelance ke, company ke..
       
      Summary:
      menulis skrip berasaskan PHP, dimana ia berfungsi checkpoint untuk menyimpan rekod keluar masuk ke dalam makmal/ small library/<insert room>.. Konsepnya sebijik macam buku log keluar masuk yg kita selalu tulis nama, tarikh/masa masuk/keluar dan sign. tapi ni web based, dengan central database. So kat mana checkpoint yg dulu kita biasa letak buku log keluar/masuk, ganti dengan komputer.
       
      process flow simple je, tapi ada beberapa perkara yg perlu dititikberatkan untuk memastikan bukan sahaja takda error, malah extensible and scalable di samping mengekalkan keringkasan pengurusan.
       
      berminat?
      aku akan terangkan detail design, dan if course bayaran boleh bincang.
×
×
  • Create New...