pls help on php login
Posted: Thu Jul 14, 2011 12:30 pm
Can anybody help me with this php code i am creating a login system where by if my user have no time in there database it would check if the time field it it is less than 0 or = to 0 i have try it so in many ways but its not work i dont know if my code have a prob or if its mysql statement have error as well here is my code below if use < it does not work when i enter more than 0 in the database like 1 or 2 and if i use the > sign as well it does not work if i have less then 0
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();
}
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}
if (isset($_POST['textfield'])) {
$loginUsername=$_POST['textfield'];
$password=$_POST['textfield2'];
// $MM_fldUserAuthorization = "time";
$MM_redirectLoginSuccess = "js.html";
$MM_redirectLoginFailed = "makesub.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_conb, $conb);
$LoginRS__query=sprintf("SELECT username, passcode, time FROM log WHERE username=%s AND passcode=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text") );
$LoginRS = mysql_query($LoginRS__query, $conb) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
//compare the expiry time with the current time
if ( $LoginRS['time'] > 0 )
{
header("Location: " . $MM_redirectLoginSuccess );
}
else
{
header("Location: ". $MM_redirectLoginFailed );
}
$loginStrGroup ="";
//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;
if (isset($_SESSION['PrevUrl']) && false) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
//header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();
}
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}
if (isset($_POST['textfield'])) {
$loginUsername=$_POST['textfield'];
$password=$_POST['textfield2'];
// $MM_fldUserAuthorization = "time";
$MM_redirectLoginSuccess = "js.html";
$MM_redirectLoginFailed = "makesub.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_conb, $conb);
$LoginRS__query=sprintf("SELECT username, passcode, time FROM log WHERE username=%s AND passcode=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text") );
$LoginRS = mysql_query($LoginRS__query, $conb) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
//compare the expiry time with the current time
if ( $LoginRS['time'] > 0 )
{
header("Location: " . $MM_redirectLoginSuccess );
}
else
{
header("Location: ". $MM_redirectLoginFailed );
}
$loginStrGroup ="";
//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;
if (isset($_SESSION['PrevUrl']) && false) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
//header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>