hi,
this is the php script
<?
$db="upentrg";
$table="login";
$userid=$_POST['userid'];
$password=$_POST['password'];
if($userid == '' || $password == '')
{
header('Location:login.php?refer='.urlencode($psRefer));
//echo "<script>alert('user n password x masuk');</script>";
}
else
{
$con=mysql_connect("localhost","root","");
mysql_select_db($db,$con);
$q="select id, MD5(UNIX_TIMESTAMP() + id + RAND(UNIX_TIMESTAMP())) GUID from $table where userid ='$userid' AND password='$password'";
$rslt=mysql_query($q,$con);
if(mysql_num_rows($rslt))
{
$prslt=mysql_fetch_row($rslt);
$q="update $table set GUID='$prslt[1]' WHERE id = $prslt[0]";
mysql_query($q,$con);
setcookie("session_id",$prslt[1]);
if(!$psRefer)
{
$psRefer='index1.php';
header('Location:'.$psRefer);
}
}
else
{
header('Location:login.php?refer='.urlencode($psRefer));
//echo "<script>alert('x select database');</script>";
}
}
?>
and
<html>
<head>
<title>Login</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script>
function changeScrollbarColor(C){
if (document.all){
document.body.style.scrollbarBaseColor = C
}
}
</script>
<style>
body{
scrollbar-base-color:#F0D9A4
}
</style>
<link rel="stylesheet" href="_notes/tganuwebcss11" type="text/css">
<style type="text/css">
<!--
-->
body {
margin-top:100px;
}
</style>
</head>
<body bgcolor="#FAEDCF">
<form action= "dblogin.php" method="post">
<div align="center">
<table width="545" border="2" bgcolor="#FFFFFF">
<tr bgcolor="#F0D9A4">
<td colspan="2"><div align="center"><font color="#000000" size="4" face="Arial, Helvetica, sans-serif">
<strong>LOGIN</strong></font></div></td>
</tr>
<tr>
<td colspan="2">
<div align="right">
<table width="100%" border="0"bgcolor="#F8E3B8">
<tr>
<td colspan="2">
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td width="46%"> </td>
<td width="54%"></td>
</tr>
<tr>
<td><div align="right"><strong><font size="2" face="Arial, Helvetica, sans-serif">User Name:</font></strong></div></td>
<td><strong><font size="2" face="Arial, Helvetica, sans-serif">
<input type="text" name="userid">
</font></strong></td>
</tr>
<tr>
<td><div align="right"><strong><font size="2" face="Arial, Helvetica, sans-serif">Password:</font></strong></div></td>
<td><strong><font size="2" face="Arial, Helvetica, sans-serif">
<input type="password" name="password">
</font></strong></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="submit" value="Login"> <input type="submit" name="reset" value="Batal"></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td><input type="hidden" name="psRefer" value="<? echo($refer) ?>">
<font size="2" face="Arial, Helvetica, sans-serif"><strong></strong></font></td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</div>
</body>
</html>
and
<?php
session_start();
// Check for a cookie, if none got to login page
if(!isset($user_name) | !isset($password)) {
header('Location:login.php');
//header('Location:/vo/servlet/portal?render=on');
//.urlencode($PHP_SELF.'?'.$HTTP_SERVER_VARS['QUERY_STRING']));
}
$expirationtime=time()-12000;
// Try to find a match in the database
$GUID = $HTTP_COOKIE_VARS['session_id'];
$hDB = mysql_connect("localhost","root","");
mysql_select_db('upentrg', $hDB);
$sQuery = "Select *From users where user_name='$user_name' and password='$password'";
$hResult = mysql_query($sQuery, $hDB);
if(!mysql_num_rows($hResult)) {
// No match for guid
header('Location:/login.php?refer=');
//header('Location:/vo/servlet/portal?render=on');
//.urlencode($PHP_SELF.'?'.$HTTP_SERVER_VARS['QUERY_STRING']));
//}
?>
I am using MySQl Ver 4.2 with PHP4 and Apache2.
Thanks