On Sun, 01 Aug 2004 15:55:47 GMT, A strange species called Bob
<bo*@dont.spam. me> wrote:
On Sun, 01 Aug 2004 16:14:12 +0100, John wrote:
Hello.
I want to get this blasted .htaccess file sorted out, so I can have
sessions without register_global s being on.
I use sessions with register_global s off and without any .htaccess file at
all. (I am running Linux so perhaps things are somewhat different on
Windows.)
It took me a little while to work out the changes needed with the newer
PHP and with register_global s set to "Off". It is reasonably well
described on the php web site:
http://www.php.net/manual/en/function.session-start.php
http://www.php.net/manual/en/functio...n-register.php
...and other pages...
I don't understand any of the things on the php manual site. They are
too complicated and not explained clearly or simply, definitely not
for beginners.
I've been told in this group by quite a few people that I need to use
a .htaccess file to enable sessions with globals turned off.
If I don't need to do that and can just use $_SESSION, can I just
delete this .htaccess file? And what about all the settings I changed
to try and get the .htaccess file to work? Do I change them back?
Also if all I need to do is use this superglobal $_SESSION, what is
wrong with the login pages I have made by following the book I am
reading through? Why wont these work?
When I register it is fine, but when I try and login, it takes me back
to the index file instead of the url I was trying to go to in the
first place before logging in, despite having ticked the box to Go to
previous URL if it exists within the server behaviours for Log In
User.
When I try click the link I was originally going to after logging in
without seeing the login failed page, it still takes me back to the
login page and not the page I want to go to.
<?php require_once('C onnections/conn_newland.ph p'); ?>
<?php
// *** Validate request to login to this site.
session_start() ;
$loginFormActio n = $_SERVER['PHP_SELF'];
if (isset($accessc heck)) {
$GLOBALS['PrevUrl'] = $accesscheck;
session_registe r('PrevUrl');
}
if (isset($_POST['username'])) {
$loginUsername= $_POST['username'];
$password=$_POS T['pwd'];
$MM_fldUserAuth orization = "userGroup" ;
$MM_redirectLog inSuccess = "index.php" ;
$MM_redirectLog inFailed = "login_failed.p hp";
$MM_redirecttoR eferrer = true;
mysql_select_db ($database_conn _newland, $conn_newland);
$LoginRS__query =sprintf("SELEC T username, pwd, userGroup FROM
tbl_users WHERE username='%s' AND pwd='%s'",
get_magic_quote s_gpc() ? $loginUsername :
addslashes($log inUsername), get_magic_quote s_gpc() ? $password :
addslashes($pas sword));
$LoginRS = mysql_query($Lo ginRS__query, $conn_newland) or
die(mysql_error ());
$loginFoundUser = mysql_num_rows( $LoginRS);
if ($loginFoundUse r) {
$loginStrGroup = mysql_result($L oginRS,0,'userG roup');
//declare two session variables and assign them
$GLOBALS['MM_Username'] = $loginUsername;
$GLOBALS['MM_UserGroup'] = $loginStrGroup;
//register the session variables
session_registe r("MM_Username" );
session_registe r("MM_UserGroup ");
if (isset($_SESSIO N['PrevUrl']) && true) {
$MM_redirectLog inSuccess = $_SESSION['PrevUrl'];
}
header("Locatio n: " . $MM_redirectLog inSuccess );
}
else {
header("Locatio n: ". $MM_redirectLog inFailed );
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Newlan d Tours: Log In</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
<link href="css/newland.css" rel="stylesheet " type="text/css" />
<script language="JavaS cript" type="text/JavaScript">
<!--
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document;
if((p=n.indexOf ("?"))>0&&paren t.frames.length ) {
d=parent.frames[n.substring(p+1 )].document; n=n.substring(0 ,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.fo rms.length;i++)
x=d.forms[i][n];
for(i=0;!x&&d.l ayers&&i<d.laye rs.length;i++)
x=MM_findObj(n, d.layers[i].document);
if(!x && d.getElementByI d) x=d.getElementB yId(n); return x;
}
function MM_validateForm () { //v4.0
var
i,p,q,nm,test,n um,min,max,erro rs='',args=MM_v alidateForm.arg uments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2];
val=MM_findObj( args[i]);
if (val) { nm=val.name; if ((val=val.value )!="") {
if (test.indexOf(' isEmail')!=-1) { p=val.indexOf(' @');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain
an e-mail address.\n';
} else if (test!='R') { num = parseFloat(val) ;
if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
if (test.indexOf(' inRange') != -1) { p=test.indexOf( ':');
min=test.substr ing(8,p); max=test.substr ing(p+1);
if (num<min || max<num) errors+='- '+nm+' must contain a
number between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is
required.\n'; }
} if (errors) alert('The following error(s) occurred:\n'+er rors);
document.MM_ret urnValue = (errors == '');
}
//-->
</script>
</head>
<body>
<a href="#top"><im g src="images/spacer.gif" alt="Skip to main page
content." width="1" height="1" border="0" align="left" /></a>
<table width="750" border="0" cellpadding="3" cellspacing="0" >
<tr>
<td><img src="images/banner_left.jpg " width="451" height="68"
alt="Newland Tours Banner, Left" /></td>
<td width="280"><im g src="images/banner_right.jp g" width="276"
height="68" alt="Newland Tours Banner, Right" /></td>
</tr>
<tr>
<td><img src="images/navbar.gif" name="navbar" width="450"
height="20" border="0" usemap="#navbar Map" alt="Navigation Bar"
/></td>
<td><img name="copyright _bar" src="images/copyright_bar.g if"
width="272" height="20" border="0" alt="Copyright 2004 Newland Tours"
/></td>
</tr>
<tr>
<td colspan="2">
<h1><br />
<a name="top" id="top"></a>Please Log In </h1>
<form name="frm_login " id="frm_login" method="POST" action="<?php
echo $loginFormActio n; ?>">
<table width="95%" border="0" cellspacing="0" cellpadding="3" >
<tr>
<td>Email Address </td>
<td><input name="username" type="text" id="username"
size="55" /></td>
</tr>
<tr>
<td>Password</td>
<td><input name="pwd" type="password" id="pwd" /></td>
</tr>
<tr>
<td> </td>
<td><input name="Submit" type="submit"
onclick="MM_val idateForm('user name','','RisEm ail','pwd','',' R');return
document.MM_ret urnValue" value="Submit" /></td>
</tr>
</table>
<p> </p>
</form>
<p>If you don't already have an account, please <a
href="register. php">register</a> for a free account. </p>
</td>
</tr>
</table>
<br />
<br />
<map name="navbarMap " id="navbarMap" >
<area shape="rect" coords="1,0,62, 20" href="index.php " alt="Home" />
<area shape="rect" coords="71,0,11 7,20" href="about.php " alt="About"
/>
<area shape="rect" coords="129,0,1 96,20" href="tours.php " alt="Find
Tours" />
<area shape="rect" coords="209,0,3 11,20" href="profiles. php"
alt="Country Profiles" />
<area shape="rect" coords="327,0,4 34,20" href="contact.p hp"
alt="Contact An Agent" />
</map>
</body>
</html>
John