btw klo yg d atas mo buat login dan macem2 pm g aja tar g kirimin cth sederhana buat login register dan lain2 ya pake databasenya biasa sih mysql download xampp aja dah 1 paket phpmyadmin mysql
Printable View
btw klo yg d atas mo buat login dan macem2 pm g aja tar g kirimin cth sederhana buat login register dan lain2 ya pake databasenya biasa sih mysql download xampp aja dah 1 paket phpmyadmin mysql
nah tuh kk sederhananya kyk gt do login itu bt memproses data setelah klik submit d form login, cm klo skrg keren2 pada make ajax jd gk sah lempar2an data lgsg d proses d situ moga2 membantuCode:LOGIN :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.style1 {
color: #FF0000;
font-style: italic;
}
-->
</style></head>
<body>
<form name="form1" method="post" action="dologin.php">
<p align="center"><img width="780" height="87" src="bank_clip_image002.jpg"></p>
<div align="center">
<table width="200" border="1" align="center">
<tr>
<td>Username</td>
<td>:</td>
<td><input name="txtUser" type="text" id="txtUser"></td>
</tr>
<tr>
<td>Password</td>
<td>:</td>
<td><input name="txtPass" type="password" id="txtPass"></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
</div>
<p align="center"> </p>
<p align="center"><?php $status =$_REQUEST['err']; if($status == 1){ echo "invalid login";} else if($status == 2) { echo "registrasi berhasil";}else if($status == 3) { echo "harap login terlebih dahulu" ;}?> </span></p>
</form>
</body>
</html>
DO LOGIN :
<?PHP
session_start();
include "konekdb.php";
$user = $_REQUEST['txtUser'];
$pass = $_REQUEST['txtPass'];
$query = "select * from mslogin where username = '$user' and password = '$pass'";
$rs = mysql_query($query,$conn);
if(mysql_num_rows($rs) == 0){
mysql_close($conn);
header("location:login.php?err=1");
exit(0);
}else{
$_SESSION['usr'] = $user;
mysql_close($conn);
header("location:home.php");
exit(0);
}
?>
REGISTER :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.style1 {
color: #FF0000;
font-style: italic;
}
-->
</style></head>
<body>
<form name="form1" method="post" action="doregister.php">
<p align="center"><img width="780" height="87" src="bank_clip_image002.jpg"></p>
<div align="center">
<table width="200" border="1" align="center">
<tr>
<td>Username</td>
<td>:</td>
<td><input name="txtUser" type="text" id="txtUser"></td>
</tr>
<tr>
<td>Password</td>
<td>:</td>
<td><input name="txtPass" type="password" id="txtPass"></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><input type="submit" name="Submit" value="Register"></td>
</tr>
</table>
</div>
<p align="center"><a href="karyawan.php">BACK</a></p>
<p align="center"> <?php echo $_REQUEST['err'];?></p>
<p align="center"> </p>
<p align="center"> </p>
</form>
</body>
</html>
DO REGISTER :
<?php
session_start();
include "konekdb.php";
$user=$_REQUEST['txtUser'];
$pass=$_REQUEST['txtPass'];
$query = "select *from mslogin where username = '$user' and password = '$pass'";
$rs = mysql_query($query,$conn);
if($user == "")
{
header("location:register.php?err=harap isi username");
}else if($pass == "")
{
header("location:register.php?err=harap isi password");
}else if(mysql_num_rows($rs) == 0)
{
$queryinsert = "insert into mslogin (username,password) values ('$user','$pass')";
$rd = mysql_query($queryinsert,$conn);
header("location:login.php?err=2");
}else if(mysql_num_rows($rs) !=0)
{
header("location:register.php?err=username telah ada");
}
?>
DO LOGOUT :
<?php
session_start();
session_unset();
session_destroy();
echo '<center>You are now logout.</center><br>';
echo '<meta http-equiv="refresh" content="1;URL=login.php">';
?>
$query = "select *from mslogin where username = '$user' and password = '$pass'";
paling sneng liat ini brubah jd:
$query = "select *from mslogin where username = ''or ''='' and password = ''or ''=''";
hehe
Ok thanks,...
btw tuh gunain mysql lagi kah ?
gmn gunain php ke mysql ?
iya,. yg dikasih losantega tuh pake sql n php,. cm untuk koneksi ke dbny lom dia kasih scriptny,. dia pake nama file konekdb.php (liat di include method login)
biasanya gini:
variable terserah ya mo dikasih nm paan asal konsisten, "username","password", ama "mydata" isi ma username,passwd si sql server,. "mydata" isi ma nama databasenyCode:<?php
$dbuser="username";
$dbpass="password";
$dbname="mydata"; //the name of the database
$handle = mysql_connect("localhost", $dbuser, $dbpass)
or die("Connection Failure to Database");
echo "Connected to database server<br>";
mysql_select_db($dbname, $handle) or die ($dbname . " Database not found." . $dbuser);
echo "Database " . $database . " is selected";
mysql_close($handle);
?>
yo i betul kk php dan mysql masih pemula juga kok kita bisa sama2 belajar ama abang bloodiez yg sakti... abang blood dewa nih kyknya btw klo mysql mo d akses 2 komputer tuh gimana sih? jd kom 1 sebagai seerver mysql dan usernya juga, 1 lagi link k databasenya mysqlnya itu bantuin babang blood
klo konekdbnya d search aja mysql_connect("localhost","","") lupa2 inget terus mysql_select_db nah bt milih databasenya musti buka cm malez dah terlanjur ngetik hehe
thankyou buat losantega dan bl00d13z ^^
mksdny diakses 2 komp apa ngakses 2 database name? klo diakses 2 komp asalbner udah pasti bisa diakses banyak komp,. localhostny ganti ja ma IP/domain [klo seumpama sql server ada di tmpt lain] cb jelasin lg yg ditanyain yg mn,. aga bngung gw nangkep prtnyaanny,.gw ga terlalu bnyk tau klo soal ginian,. jd ga usa sbut dewa2/sakti/master,.=_=Code:mysql_connect("localhost", $dbuser, $dbpass)
wkwkw maap om blood agak binmgung ya dakses 2 komp, itu pake my sql connect kan ya tinggal, ipnya? jd d loclal host itu kita ganti ip addressnya kan ya? sep2
tu kode2 HTML
yang buat desain web pake notepad
yg tau tulis aja....
nanti gw copas
buat di pelajarin
gk komplit juga gpp
asal ada aja
______________________________________________
mimpi menjadi premium member
menunggu sampai kapanpun...
ya om blood maklum blom pengalaman lgsg nih, biasa maennya local bt komputer sendiri doang coba2nya hehehe, blom lgsg terjun k lapangannya sep2 tq boz gile sadis si boz blood ini ciakaka
om... klo cara send email melalui form gimana ya codingnya??
mail itu sederhananya dengan fungsi mail().
> http://id2.php.net/manual/en/function.mail.php
tapi harus diingat, ga semua mail server mo nerima email dari mail servermu.
contohnya sih yahoo yg sangat2 pemilih.