sessions of doom

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

sessions of doom

Post by shiznatix »

ok i set sessions on the 1st page everything works yes. now i move over from index.php (were i set the sessions) and im trying to cary those sessions over to profile.php. well if u toss in session_start()l in profile the sessions work but other things in the file just dont work at all but if i take out the session stuff the file works perfectly fine. here is what i got

Code: Select all

<? ob_start(); include('config.php'); session_start();

$username2 = mysql_real_escape_string($user);
trim($username2);

$query = mysql_query("SELECT * FROM users WHERE username='$username2'", $connect);
while ($info = mysql_fetch_assoc($query))&#123;
$username2 = $info&#1111;'username'];
$joindate = $info&#1111;'joindate'];
$title = $info&#1111;'title'];
$validate = $info&#1111;'validate'];
$access_level = $info&#1111;'access_level'];
echo '
<tr><th>Name:</th><td>'.$username2.'</td></tr>

<tr><th>Joined:</th><td>'.$joindate.'</td></tr>
<tr><th>Title:</th><td>'.$title.'</td></tr>
<tr><th>Status:</th><td>';
	if ($validate == "0")&#123;
	echo 'awaiting validation';
	&#125;elseif ($access_level == "0")&#123;
	echo 'banned';
	&#125;elseif ($access_level == "1")&#123;
	echo 'member';
	&#125;elseif ($access_level == "2")&#123;
	echo 'admin';
	&#125;	
echo '</td></tr>
';
&#125;
echo '</table></div><br>';

if (($_SESSION&#1111;'level'] == "1")) &#123;
echo '
<form action="profile.php?u='.$username2.'" method="post">
Admin Actions for User&nbsp;
<br>
Set status to: <br>

<input type="radio" name="access" value="0">Banned<br>
<input type="radio" name="access" value="1">Regular user<br>
<input type="radio" name="access" value="2">Admin<br>

<br><br><br>

Change user''s title to:
<input type="text" name="title" value=""><br><br>

<input type="submit" name="submit" value="submit">



</form>';
&#125;
if (isset($u) && $_SESSION&#1111;'level'] == "1")&#123;
	if (isset($_POST&#1111;'type']))&#123;
	$query = mysql_query("UPDATE users SET access_level='$access' WHERE username='$u'", $connect);
	&#125;
	if ($title != '')&#123;
	$query2 = mysql_query("UPDATE users SET title='$title' WHERE username='$u'", $connect);
	&#125;
header("location: profile.php?user=$u");
&#125;


?>
hunterhp
Forum Commoner
Posts: 46
Joined: Sat Jan 22, 2005 5:20 pm
Contact:

Post by hunterhp »

What exactly doesn't work when you put session_start()?
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

updating the databases, which dosnt make sence at all but it will go down and it will then redirect me but nothing will be done with the databases why?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

it's quite possible that the url variable you think should exist doesn't, because register_globals is probably off (a good thing)

$_GET['u']...
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

i added $u = $_GET['u'] to no avail
rehfeld
Forum Regular
Posts: 741
Joined: Mon Oct 18, 2004 8:14 pm

Post by rehfeld »

put this at the top of your script, and then at the very least, exercise some minor debugging methods.

Code: Select all

ini_set('display_errors', 1);
error_reporting(E_ALL);
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

never mind i had already had $_SESSION['title'] set so it was reading $title as $_SESSION['title'] and it messed everything up. fixed the problem thanks for the help guys
Post Reply