Forum Moderators: coopster

Message Too Old, No Replies

PHP Error Explenation

         

wfernley

3:27 pm on Jun 25, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hello. I am getting this error when I am using Sessions.

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

Now my hosting company wont change anything for me, and register_golbals is set to off - Which I want it to be because of security issues I hear.

Can I use sessions?

Thanks :)

Wes

HelenDev

3:40 pm on Jun 25, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You should still be able to use sessions. Can you post the code which is giving an error?

wfernley

3:43 pm on Jun 25, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sure. Here is the code. I put **** for the table name.

<?php
include("includes/application.php");

if (isset($_POST['submit'])) {

// check username and password
$username = $_POST['username'];
$password = $_POST['password'];

if (!isset($username) ¦¦!isset($password)) {
print "Please enter all the information <br>";
print "<a href='login.php'>Click Here</a> to return to the login form.";
die;
}

// convert the password to md5 hash
$password = md5($password);

// check the database for the username and password
$user_check = mysql_query("SELECT * FROM ******* WHERE username = '$username' AND password = '$password'");
$user = mysql_num_rows($user_check);

if ($user > 0) {
$user_query = mysql_query("SELECT * FROM ******* WHERE username = '$username' AND password = '$password'");
$userinfo = mysql_num_rows($user_query);
session_register('username');
$_SESSION['username'] = $userinfo['username'];
session_register('firstname');
$_SESSION['firstname'] = $userinfo['firstname'];
session_register('lastname');
$_SESSION['lastname'] = $userinfo['lastname'];
session_register('email');
$_SESSION['email'] = $userinfo['email'];
print "You are now logged in ".$_SESSION['firstname'].".<br>";
print "<a href='index.php'>Click Here</a> to go to the admin section.";

} else {
print "Your login information was incorrect. Please enter your correct username and password.";
print "<a href='login.php'>Click Here</a> to return to the login form.";
}

} else {
?>
<form method="POST" action="<?php echo $_SERVER['PHP_SELF'];?>">
<table width="450" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="125"><b>Username:</b></td>
<td width="325"><input name="username" type="text" id="username"></td>
</tr>
<tr>
<td width="125"><b>Password:</b></td>
<td width="325"><input name="password" type="password" id="password"></td>
</tr>
</table>
<input type="submit" name="submit" value="Submit">
</form>

<?php }?>

wfernley

3:48 pm on Jun 25, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hey I just found my problem.

I was using a mysql_num_rows instead of a mysql_fetch_array.

So that fixed my problem :)

Thanks for your help though :)

If you are looking through my code, let me know what you think. I am still a novice and wouldn't mind some criticism on my code :)

Wes