note 34684 added to function.session-start
| From: | tartaruga7 at yahoo dot com | Date: | Mon, 04 Aug 2003 03:15:50 +0000 |
| Subject: | note 34684 added to function.session-start | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-53284@lists.php.net to get a copy of this message | ||
I am have a problem with getting the following code to work. Could someone tell me how I need to
modify it so I can name the session before starting it and what I should name it? The public pages
are connecting to the DB fine, it's the admin pages with the user login that will not connect
correctly.
Your help would be greatly appreciated.
Thanks.
Brian
<?php require_once('../Connections/connNew.php'); ?>
<?php
/* set the session name to WebsiteID */
$previous_name = session_name("WebsiteID");
echo "The previous session name was $previous_name<p>";
session_name();
// *** 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['userLogin'])) {
$FF_valUsername=$HTTP_POST_VARS['userLogin'];
$FF_valPassword=$HTTP_POST_VARS['userPW'];
$FF_fldUserAuthorization="";
$FF_redirectLoginSuccess="index.php";
$FF_redirectLoginFailed="login2.php";
$FF_rsUser_Source="SELECT username, password ";
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_connNew, $connNew);
$FF_rsUser=mysql_query($FF_rsUser_Source, $connNew) 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");
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;
header ("Location: $FF_redirectLoginSuccess");
exit;
}
mysql_free_result($FF_rsUser);
session_register("FF_login_failed");
$FF_login_failed = true;
header ("Location: $FF_redirectLoginFailed");
exit;
}
?>
<html>
<head>
<title>TCSS Administration Log In</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<p align="center"><font size="4" face="Verdana, Arial, Helvetica,
sans-serif"><strong>Town
Center Self Storage<br>
Administration</strong></font></p>
<p align="center"><img src="../img/house.gif" width="314"
height="141"></p>
<form name="form1" method="POST" action="<?php echo
$FF_LoginAction?>">
<table width="306" border="2" align="center"
cellpadding="2" cellspacing="0" bordercolor="#99CC99">
<tr>
<td width="126"><div align="right"><font size="3"
face="Verdana, Arial, Helvetica, sans-serif"><strong>User
Name: </strong></font></div></td>
<td width="166"><input name="userLogin" type="text"
id="userLogin2"></td>
</tr>
<tr>
<td><div align="right"><font size="3" face="Verdana,
Arial, Helvetica,
sans-serif"><strong>Password:</strong></font></div></td>
<td><input name="userPW" type="password"
id="userPW2"></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input type="submit" name="Submit" value="Login">
</div></td>
</tr>
</table>
</form>
</body>
</html>
----
Manual Page -- http://www.php.net/manual/en/function.session-start.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+34684
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+34684&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+34684&report=yes