Good day.!
I am having problem with passing the parameter value. I have a page called index.php. This page has a textbox named "username" when the user login and type his/her user name in the textbox named "username" i want the data of that user to be displayed in the next page called enrolselection.php. I have already a recordset in the index.php which holds the login statement. below is the recordset:
if (!isset($_SESSION)) {
session_start();
}
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}
if (isset($_POST['username'])) {
$loginUsername=$_POST['username'];
$password=$_POST['password'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "enrolselection.php";
$MM_redirectLoginFailed = "invaliduser.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_enamysqldb, $enamysqldb);
$LoginRS__query=sprintf("SELECT username, password FROM studentregistration WHERE username=%s AND password=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
$LoginRS = mysql_query($LoginRS__query, $enamysqldb) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$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 );
}
}
the above recordset works fine. When the user login success, it display the enrolselection.php. My problem is, how can i ddisplay the data of the user who login in enrolselection.php that caomes from mysql table.? here is my recordset in enrolselection.php. I dont know what to put in the where statement of my sql. please help.
<?php require_once('Connections/enamysqldb.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$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;
}
}
$colname_recstudinfo = "-1";
if (isset($_GET['username'])) {
$colname_recstudinfo = $_GET['username'];
}
mysql_select_db($database_enamysqldb, $enamysqldb);
$query_recstudinfo = sprintf("SELECT * FROM studentregistration WHERE username = %s", GetSQLValueString($colname_recstudinfo, "text"));
$recstudinfo = mysql_query($query_recstudinfo, $enamysqldb) or die(mysql_error());
$row_recstudinfo = mysql_fetch_assoc($recstudinfo);
$totalRows_recstudinfo = mysql_num_rows($recstudinfo);
Ive done this in asp by just passing the parameter value of index.php to enrlselection.php that holds the data of username textbox. here is my code in asp
<%
Dim MMColParam
MMColParam = "1"
If (Request.QueryString("username") <> "") Then
MMColParam = Request.QueryString("username")
End If
%>
<%
recdisplaysearchcontent.Source = "SELECT * FROM tblsearch_content WHERE index = " + Replace(MMColParam, "'", "''") + " ORDER BY index ASC"
%>
I dont know how to convert this asp code in php.Please help.!!
Thank you and God bless.!!