Page 1 of 1

My Login would not work after i have stored into the db

Posted: Sat Jul 02, 2011 1:33 pm
by oyedele
<?php require_once('../Connections/Konnect.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
?>
<?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['Matric_No'])) {
$loginUsername=$_POST['Matric_No'];
$password=$_POST['Password'];
$MM_fldUserAuthorization = "Phone_Number";
$MM_redirectLoginSuccess = "mainpage.php";
$MM_redirectLoginFailed = "Newregister.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_Konnect, $Konnect);

$LoginRS__query=sprintf("SELECT Matric_No, Password, Phone_Number FROM student_details WHERE Matric_No=%s AND Password=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));

$LoginRS = mysql_query($LoginRS__query, $Konnect) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {

$loginStrGroup = mysql_result($LoginRS,0,'Phone_Number');

//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 );
}
}
?>

Re: My Login would not work after i have stored into the db

Posted: Sat Jul 02, 2011 3:33 pm
by Pazuzu156

Re: My Login would not work after i have stored into the db

Posted: Mon Jul 04, 2011 6:26 am
by social_experiment
@OP : it also helps if give a bit more information about your problem. The title of a post is usually not reserved for the problem itself. By giving more information more people understand the problem and thus your problem can be solved much faster.

Re: My Login would not work after i have stored into the db

Posted: Mon Jul 04, 2011 6:46 am
by Apollo
And if you want people to read your problem and reply: viewtopic.php?t=21171