I am studying a book which bases it's examples on setting register_globals to on as register_globals is a security risk (or so I'm told, I don't understand why, but don't really care at this stage of my learning).
So, I am trying to use a session to enable a personalised greeting when a user logs on based on examples from the book. This is what I have so far...
index.php containing a logon box and a password box. PHP code on this page is:
<?php
session_register('entered_username');
?>
Now the user enters his/her username and password and it is checked by login.php containing:
<?php
include("common.php");
if(!($link_id = mysql_connect($Host, $User, $Pass)))
{
die(mysql_error());
}
mysql_select_db($DB);
$sql = "SELECT ID FROM " . $Table . " WHERE username='" . $_POST['username'] . "' AND password='" . md5($_POST['password']) . "' LIMIT 1";
if(!($result = mysql_query($sql)))
{
die(mysql_error());
}
if(mysql_num_rows($result) == 1)
{
$entered_username="" . $_POST['username'];
echo "You have been validated " . $entered_username . ". <br><a href='member.php'>Click here</a> to return to the login page.";
}
else
{
echo "Login failure";
}
?>
Although the login.php page shows up, I get this message:
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 I know it's giving me the answer here but I would like to know why I'm following the instructions before I move on so could anyone either explain or point me to a link that will.
Cheers. 🙂