<?
session_start();
if(!session_is_registered(myusername)){
header("location:index.html");
}
?>
<html>
<body>
Login Successful
</body>
</html>
Sabtu, 02 April 2011
checklogin.php
<?php
$host="localhost"; // Host name
$username="root"; // Mysql username
$password="123"; // Mysql password
$db_name="satudua"; // Database name
$tbl_name="user"; // Table name
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// username and password sent from form
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
// To protect MySQL injection (more detail about MySQL injection)
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("myusername");
session_register("mypassword");
header("location:menu.html");
}
else {
echo "Wrong Username or Password";
}
?>
<br />
<a href="login.php">Kembali</a>
*phpeasystep
$host="localhost"; // Host name
$username="root"; // Mysql username
$password="123"; // Mysql password
$db_name="satudua"; // Database name
$tbl_name="user"; // Table name
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// username and password sent from form
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
// To protect MySQL injection (more detail about MySQL injection)
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("myusername");
session_register("mypassword");
header("location:menu.html");
}
else {
echo "Wrong Username or Password";
}
?>
<br />
<a href="login.php">Kembali</a>
*phpeasystep
Script Login PHP
Berikut script nya ..
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
#form1 table tr td {
color: #FFF;
}
-->
</style>
</head>
<body>
<h2><p align="center">Login</p></h2>
<form id="form1" name="frmlogin" method="post" action="checklogin.php">
<table width="347" height="154" border="1" align="center">
<tr>
<td width="95" height="42" bgcolor="#666666">Username</td>
<td bgcolor="#666666"><label>
<input type="text" name="myusername" id="myusername" />
</label></td>
</tr>
<tr>
<td height="42" bgcolor="#666666">Password</td>
<td bgcolor="#666666"><label>
<input name="mypassword" type="password" id="mypassword" />
</label></td>
</tr>
<tr>
<td colspan="2" align="center" valign="middle" bgcolor="#0066FF"><label>
<input type="submit" name="submit" id="submit" value="Submit" />
</label> <label>
<input type="reset" name="reset" id="reset" value="Reset" />
</label></td>
</tr>
</table>
</form>
</body>
</html>
Source : http://phpeasystep.com/
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
#form1 table tr td {
color: #FFF;
}
-->
</style>
</head>
<body>
<h2><p align="center">Login</p></h2>
<form id="form1" name="frmlogin" method="post" action="checklogin.php">
<table width="347" height="154" border="1" align="center">
<tr>
<td width="95" height="42" bgcolor="#666666">Username</td>
<td bgcolor="#666666"><label>
<input type="text" name="myusername" id="myusername" />
</label></td>
</tr>
<tr>
<td height="42" bgcolor="#666666">Password</td>
<td bgcolor="#666666"><label>
<input name="mypassword" type="password" id="mypassword" />
</label></td>
</tr>
<tr>
<td colspan="2" align="center" valign="middle" bgcolor="#0066FF"><label>
<input type="submit" name="submit" id="submit" value="Submit" />
</label> <label>
<input type="reset" name="reset" id="reset" value="Reset" />
</label></td>
</tr>
</table>
</form>
</body>
</html>
Source : http://phpeasystep.com/
Langganan:
Postingan (Atom)