Jump to content

Recommended Posts

i dont know what the hell im doing, im kinda going along with the flow.. i know a little php and have been doing the best i can.. okay let me paint the picture.

 

The site is for a small friendly clan site, somewhere to post images, status updates, house tournements and so forth. im pulling information from xbox.com for any account someone signs up very simple stuff.

 

My index page consists of a session then header image then an if statement, ie if logged in show Control panel, if not show login form. this all works a treat. but the only problem im having is that when the control panel.php is included getting information from my database seems to be a problem. and i get this 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

 

the coding on index.php:

<?
session_start();

// CONNECT TO THE DATABASE
mysql_connect ("localhost", "xxx", "xxx") or die ('Error: ' . mysql_error());
mysql_select_db ("xxx");

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>HSK.</title>
<style type="text/css">
<!--
body,td,th {
font-family: Helvetica, Arial , sans-serif;
color: #FFFFFF;
font-size: 12px;
}
body {
background-color: #2d2d2d;
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
#header{
width: 100%;
height: 178px;
background: url(images/header_bg.gif) repeat-x;
}
#headerInsert{
width: 1000px;
height: 178px;
background: url(images/header.gif) no-repeat center;
}
#columns{
width: 1000px;
height:auto;
}
#column1{
float:left;
width: 480px;
margin: 10px;
}
#column2{
float:left;
width: 480px;
margin: 10px;
}
a{
color: #91FF3A;
text-decoration:none;
}
a:hover{
color: #FFFFFF;
text-decoration:none;
}
-->
</style>
</head>

<body>
<div align="center">
<div id="header"><div id="headerInsert"></div></div>
<? 
if( @$_SESSION['auth'] != "yes" ){
include("login.php");
}
else{
include("cp.php");
}
?>
<div id="columns">
<div id="column1"></div>
<div id="column2">
<table width="458" border="0" cellspacing="3" cellpadding="10">
  <tr>
    <td bgcolor="#2D2D2D">New Users Signed up: </td>
    </tr>
</table>
<?
$query2 = "SELECT * FROM user ORDER BY date DESC";
$results2 = mysql_query($query2) or die ("Could not execute query");
while ($row2 = mysql_fetch_array($results2)){
extract($row2);?>
<table width="458" height="46" border="0" cellpadding="10" cellspacing="0" background="images/box_new_small.gif">
  <tr>
    <td width="20" align="center" valign="middle"><? echo"<img src='http://avatar.xboxlive.com/avatar/$gamert/avatarpic-l.png' width='20' height='20' alt='' />" ?></td>
    <td width="460" align="left" valign="middle"><? echo"<a href='page.php?id=$id'> $username </a>" ?> is now a member of the HSK. </td>
  </tr>
</table>

<? }?>
</div>
</div>
</div>
</body>
</html>

 

 

and so far for my CP page is:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>login</title>
<style type="text/css">
<!--
body,td,th {
font-family: Helvetica, Arial, sans-serif;
color: #FFFFFF;
}
body {
background-color: #323232;
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
#login{
width: 100%;
height: 50px;
border-bottom: solid 1px #555555;
background: url(images/login_box.gif) center no-repeat;
}
#loginform{
width: 939px;
height: 17px;
position:relative;
top: 12px;
left: 0px;
}
a{
color: #90FF38;
text-decoration: none;
}
.textInput {
background-color:#333333;
border:solid 1px #9A9A9A;
color: #FFFFFF;
height: 17px;
padding-left: 5px;
margin-left: 5px;
margin-right: 5px;
}
.textInput2 {
background-color:#333333;
border:solid 1px #9A9A9A;
color: #33FF00;
height: 17px;
text-align: center;
margin-left: 5px;
margin-right: 5px;
}
.submitForm{
background: url(images/button.gif) no-repeat center;
width: 60px;
height: 22px;
color:#FFFFFF;
margin-left: 4px;
margin-top: 4px;
border:none;
}
#label{
background: url(images/label.gif);
height: 22px;
width: 70px;
color:#FFFFFF;
}
-->
</style>
</head>

<body>
<div align="center">
<div id="login">
<div id="loginform">

<form id="form1" name="form1" method="post" action="login_process.php">
		<label>Welcome:</label>
		<? echo"<img src='http://avatar.xboxlive.com/avatar/$gamert/avatarpic-l.png' width='20' height='20' alt='' />" ?> 
		<? echo"<a href='page.php?id=$id'> $username </a>" ?>
<input type="button" name="Submit2" value="Logout" class="submitForm" onclick="parent.location='logout_process.php'"/>
</form>

</div>
</div>
</div>
</body>
</html>

 

how do i call my variables from an include statement and also not get the sessions error?

 

and to test it in action. http://xbox.brokenbox.co.uk

Link to comment
https://forums.phpfreaks.com/topic/174136-session-error-in-include/
Share on other sites

okay great now im being a bit noobie. but i when in the CP i have it to display the details but i cant remember how to call a session variable for reference to who your logged in as.. this is what i need the session variable is this:

 

$_SESSION['username'] = $username;

 

and i want it to get your information in the CP like this:

 

$query2 = "SELECT * FROM user WHERE=$_SESSION['username'] ";

 

 

or something like that is that how its done or is there a better method?

DON'T enable register_globals for any reason. The were turned off by default over seven years ago because they allow a hacker to set your session variables. They have also completely been removed in php6.

 

Like the error message states, this is a BUG in php that is due to an error in the way that register_globals was implemented (when register_globals are off, if you create a variable/session variable with a null value and there is a same name variable/session variable, you get that error.) Set either one or both of the settings that are mentioned in the error to OFF.

 

DON'T enable register_globals for any reason. The were turned off by default over seven years ago because they allow a hacker to set your session variables. They have also completely been removed in php6.

 

Like the error message states, this is a BUG in php that is due to an error in the way that register_globals was implemented (when register_globals are off, if you create a variable/session variable with a null value and there is a same name variable/session variable, you get that error.) Set either one or both of the settings that are mentioned in the error to OFF.

 

okay do i ask my hosting provider to do this or is this something i can do my end? if so.. how?  :-[

 

Also i still cant quite get the session variable.. im close i can feel it but im missing something this is what im trying:

 

 $query2 = "SELECT * FROM user WHERE={$_SESSION['username']}"; 

 

but its comes out wrong. should i try it without the = ?

$query2 = "SELECT * FROM user WHERE username='{$_SESSION['username']}'"; 

 

change the username to the name of the colume in your DB

 

Wooo awesome, thank you so much :) yeaaay its nice to see it finally coming together, i have never built anything as big as what i want this to turn out to be, my clan friends will be so happy to see it done too. usually im just moving vars in an out of database for very simple simple stuff.. i hope this will be much bigger :D thank you again

Okay so i tried a couple of things and didnt get anywhere. first i created my "php.ini" file and uploaded it to /MY

its had contents of:

 

session.bug_compat_­42 = 0ff
session.bug_compat_­warn = Off
display_errors = Off
display_startup_errors = Off

 

nothing changed i still got the error.. so then i tried to change the same shared name between variable and session variable

 

FROM:

session_start();
$_SESSION['auth'] = "yes";
$_SESSION[username] = $username;

 

TO:

session_start();
$_SESSION['auth'] = "yes";
$_SESSION['user'] = $username;

 

WITH THE RECIEVING END BEING:

$query2 = "SELECT * FROM user WHERE username='{$_SESSION['user']}'";

 

 

i still get the same error..im totally stuck and i cant find much documentation that i understand clearly :(

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.