Home » » Koneksi PHP dengan mySQL

Koneksi PHP dengan mySQL

Written By fasana Itech on Selasa, 10 Februari 2015 | 11.28

Selamat Berjumpa kembali di gudang skripsi, kali ini kami akan memberikan sedikit contoh sederhana koneksi PHP dengan database mySQL

Contoh sederhana koneksi :

 
<?php

   $srvr="localhost";

   $db="test";

   $usr="root";

   $pwd="test";

   mysql_connect($srvr,$usr,$pwd);

   mysql_select_db($db);

?>



Contoh Sederhana login :

 <?php session_start();
include("koneksi.php");
if(!$_POST['usertxt'] || !$_POST['pswtxt']){
 echo "<script>alert('Data tidak boleh ada yang kosong !')</script>"; 
 echo "<meta http-equiv='refresh' content='0;index.php'>";  
}else {
 $sql = "Select * from tbl_user where user='$_POST[usertxt]' And password='".md5($_POST['pswtxt'])."'";
 $proses = mysql_query($sql);
 $data = mysql_fetch_array($proses);
 $login = mysql_num_rows($proses);
 if ($login==0){
  echo "<script>alert('Password Anda salah !')</script>";
  echo "<meta http-equiv='refresh' content='0;index.php'>";
 }else{
  $_SESSION['user'] =$data['user'];
  echo "<meta http-equiv='refresh' content='0;home.php'>";
 }
}
?>

demikian semoga bermanfaat



Share this article :

1 komentar:

caipaetow mengatakan...

A review of my favorite casino - DrmCD
The casino offers some 광양 출장마사지 excellent gaming options to help you find the 강원도 출장마사지 It includes the best slots games, 의왕 출장안마 a wide range of 영천 출장샵 video games 평택 출장샵 and live dealer games

IT dan document solution

IT dan document solution

ebisnis | Tutorial Computer

IT dan document solution

Contoh Aplikasi

IT dan document solution

 
Support : bo-fsakti.blogspot.com | deddyrusdiansyah.blogspot.com | HDT.com | softwarebanten.com
Copyright © 2012 - 2018. Gudang skripsi dan Pemrograman - All Rights Reserved
Template Published by Mas Template
Proudly powered by Blogger