Page 1 of 1

sessions of doom

Posted: Sat Jan 29, 2005 9:34 pm
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;


?>

Posted: Sat Jan 29, 2005 9:38 pm
by hunterhp
What exactly doesn't work when you put session_start()?

Posted: Sat Jan 29, 2005 9:47 pm
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?

Posted: Sat Jan 29, 2005 10:49 pm
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']...

Posted: Sat Jan 29, 2005 11:07 pm
by shiznatix
i added $u = $_GET['u'] to no avail

Posted: Sun Jan 30, 2005 1:16 am
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);

Posted: Sun Jan 30, 2005 1:33 am
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