Thanks Rob. Here is basically what I am trying to do.
I want users to login (username, password). Each user has been assigned a page of entry (urlredirect) in the database (mysql) according to their user_category.
So, when a user logins successfully I want them to be redirected to their corresponding url (entry page) indicated by the urlredirect field in the database. For example one entry in the urlredirect field may simply be molluscs.php or arthropods.php.
In the first example:
Session("svURL")=MM_rsUser.Fields.Item("urlredirect")
basically what it is doing (I think) is establishing a session variable with the urlredirect field content in the database. I BELIEVE (although I am very uncertain that it goes somewhere here).
The 2nd example is equivalent to the header (location) function of php but again I am uncertain how to reference the session variable.
Response.Redirect "http://website/" & Session("svUrl") &""
Here is the section of code I BELIEVE these two need to be placed into: I have placed the ASP code where I believe the PHP code needs to go
if(mysql_num_rows($FF_rsUser) > 0) {
// username and password match - this is a valid user
$MM_Username=$FF_valUsername;
session_register("MM_Username");
Session("svURL")=MM_rsUser.Fields.Item("urlredirect") ;
if ($FF_fldUserAuthorization != "") {
$MM_UserAuthorization=$row_FF_rsUser[$FF_fldUserAu
thorization];
} else {
$MM_UserAuthorization="";
}
session_register("MM_UserAuthorization");
if (isset($accessdenied) && false) {
$FF_redirectLoginSuccess = $accessdenied;
}
mysql_free_result($FF_rsUser);
session_register("FF_login_failed");
$FF_login_failed = false;
Response.Redirect "http://website/" & Session("svUrl") &"" ;
exit;
}
All the code for the page is listed below (again you will see the two ASP statements):
<?php require_once('Connections/connlogin.php'); ?>
<?php
mysql_select_db($database_connlogin, $connlogin);
$query_rslogin = "SELECT * FROM users";
$rslogin = mysql_query($query_rslogin, $connlogin) or die(mysql_error());
$row_rslogin = mysql_fetch_assoc($rslogin);
$totalRows_rslogin = mysql_num_rows($rslogin);
// *** Start the session
session_start();
// *** Validate request to log in to this site.
$FF_LoginAction = $HTTP_SERVER_VARS['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING']) && $HTTP_SERVER_VARS['QUERY_STRING']!="") $FF_LoginAction .= "?".$HTTP_SERVER_VARS['QUERY_STRING'];
if (isset($HTTP_POST_VARS['username'])) {
$FF_valUsername=$HTTP_POST_VARS['username'];
$FF_valPassword=$HTTP_POST_VARS['password'];
$FF_fldUserAuthorization="";
$FF_redirectLoginFailed="error.php";
$FF_rsUser_Source="SELECT username, password, urlredirect ";
if ($FF_fldUserAuthorization != "") $FF_rsUser_Source .= "," . $FF_fldUserAuthorization;
$FF_rsUser_Source .= " FROM users WHERE username='" . $FF_valUsername . "' AND password='" . $FF_valPassword . "'";
mysql_select_db($database_connlogin, $connlogin);
$FF_rsUser=mysql_query($FF_rsUser_Source, $connlogin) or die(mysql_error());
$row_FF_rsUser = mysql_fetch_assoc($FF_rsUser);
if(mysql_num_rows($FF_rsUser) > 0) {
// username and password match - this is a valid user
$MM_Username=$FF_valUsername;
session_register("MM_Username");
Session("svURL")=MM_rsUser.Fields.Item("urlredirect") ;
if ($FF_fldUserAuthorization != "") {
$MM_UserAuthorization=$row_FF_rsUser[$FF_fldUserAuthorization];
} else {
$MM_UserAuthorization="";
}
session_register("MM_UserAuthorization");
if (isset($accessdenied) && false) {
$FF_redirectLoginSuccess = $accessdenied;
}
mysql_free_result($FF_rsUser);
session_register("FF_login_failed");
$FF_login_failed = false;
Response.Redirect "http://website/" & Session("svUrl") &"" ;
exit;
exit;
}
mysql_free_result($FF_rsUser);
session_register("FF_login_failed");
$FF_login_failed = true;
header ("Location: $FF_redirectLoginFailed");
exit;
}
?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form name="form1" method="post" action="<?php echo $FF_LoginAction?>">
<table width="55%" border="1" cellspacing="3" cellpadding="3">
<tr>
<td>username</td>
<td>
<input name="username" type="text" id="username"></td>
</tr>
<tr>
<td>password</td>
<td>
<input name="password" type="text" id="password"></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td>
<input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
</form>
</body>
</html>
<?php
mysql_free_result($rslogin);
?>