|
-
Sep 6th, 2003, 06:24 AM
#1
Thread Starter
Lively Member
session unknown error ... [RESOLVED]
hello I am getting an error:
Warning: Unknown(): Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively. in Unknown on line 0
what is this error?
the code that I use is this:
PHP Code:
<?
$username = $_POST['username'];
$password = $_POST['password'];
$result = mysql_query("SELECT * FROM admin",$mysql_link) ;
$isAuth = false; //set to false originally
while($row = mysql_fetch_array($result))
{
if($row['Name'] === $username && $row['Pass']===$password) //above row checks to see if username/password combination exists
{
$isAuth = true;
session_start();
session_register('username');
}
}
if($isAuth)
{
print "logged in successfully<br>";
print "<A href='index.php'>Go to Admin Panel</a>";
}
else //if login/pass does not exist
{
header("Location: wrong-url.com");
}
?>
<html>
<head>
<META NAME="Author" CONTENT="Yair Ben Ari">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-8-i">
<Link REL=STYLESHEET HREF="style.css" TYPE="text/css">
<title>login</title>
</head>
<BODY>
<?
if($isAuth)
{
include('header.php');
include('adminmenu.inc');
}
?>
is it a deprecated code? what can I do to fix it?
I read that I should use this:
PHP Code:
$_SESSION['var'] = 'something';
unset($_SESSION['var2']);
instead of the way I use session_register...
but how can I use it in this code can someone help please?
Yair
Last edited by yair24; Sep 15th, 2003 at 01:44 AM.
-
Sep 6th, 2003, 09:45 PM
#2
Stuck in the 80s
I think your problem may lie with this code:
Code:
$username = $_POST['username'];
$password = $_POST['password'];
Which I DON'T UNDERSTAND it's purpose, and your naming of the session variable "username".
You're not getting an error, you're getting a warning (which you can shut off in the php.ini, by the way), and I'm sure it's thinking that you're using $username as a session variable, rather than the one you created.
My advice would be to name your session variable as "s_username" instead of "username".
If the warning then goes away, my guess was right. Otherwise, I have no idea.
So give it a try and let me know. And you can always just shut off the warnings in the ini. Search these forums to find out how.
-
Sep 7th, 2003, 12:28 PM
#3
Member
I read that I should use this:
And your right. If your using $_SESSION, then you shouldn't use session_register(), session_is_registered(), and session_unregister().
Tru rewriting it to this
PHP Code:
<?php
// no need to make a 2 variable with the same value, took them out
$result = mysql_query("SELECT * FROM admin",$mysql_link) ;
$isAuth = false; //set to false originally
while($row = mysql_fetch_array($result))
{
if($row['Name'] === $_POST['username'] && $row['Pass'] === $_POST['password']) //above row checks to see if username/password combination exists
{
$isAuth = true;
session_start();
// create a new session variable
$_SESSION['username'] = $_POST['username'];
}
}
if($isAuth)
{
print "logged in successfully<br>";
print "<A href='index.php'>Go to Admin Panel</a>";
}
else //if login/pass does not exist
{
header("Location: wrong-url.com");
}
?>
<html>
<head>
<META NAME="Author" CONTENT="Yair Ben Ari">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-8-i">
<Link REL=STYLESHEET HREF="style.css" TYPE="text/css">
<title>login</title>
</head>
<BODY>
<?
if($isAuth)
{
include('header.php');
include('adminmenu.inc');
}
?>
-
Sep 8th, 2003, 11:00 AM
#4
Thread Starter
Lively Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|