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
shiznatix
DevNet Master
Posts: 2745 Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:
Post
by shiznatix » Sat Jan 29, 2005 9:34 pm
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)){
$username2 = $infoї'username'];
$joindate = $infoї'joindate'];
$title = $infoї'title'];
$validate = $infoї'validate'];
$access_level = $infoї'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"){
echo 'awaiting validation';
}elseif ($access_level == "0"){
echo 'banned';
}elseif ($access_level == "1"){
echo 'member';
}elseif ($access_level == "2"){
echo 'admin';
}
echo '</td></tr>
';
}
echo '</table></div><br>';
if (($_SESSIONї'level'] == "1")) {
echo '
<form action="profile.php?u='.$username2.'" method="post">
Admin Actions for User
<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>';
}
if (isset($u) && $_SESSIONї'level'] == "1"){
if (isset($_POSTї'type'])){
$query = mysql_query("UPDATE users SET access_level='$access' WHERE username='$u'", $connect);
}
if ($title != ''){
$query2 = mysql_query("UPDATE users SET title='$title' WHERE username='$u'", $connect);
}
header("location: profile.php?user=$u");
}
?>
hunterhp
Forum Commoner
Posts: 46 Joined: Sat Jan 22, 2005 5:20 pm
Contact:
Post
by hunterhp » Sat Jan 29, 2005 9:38 pm
What exactly doesn't work when you put session_start()?
shiznatix
DevNet Master
Posts: 2745 Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:
Post
by shiznatix » Sat Jan 29, 2005 9:47 pm
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?
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sat Jan 29, 2005 10:49 pm
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']...
shiznatix
DevNet Master
Posts: 2745 Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:
Post
by shiznatix » Sat Jan 29, 2005 11:07 pm
i added $u = $_GET['u'] to no avail
rehfeld
Forum Regular
Posts: 741 Joined: Mon Oct 18, 2004 8:14 pm
Post
by rehfeld » Sun Jan 30, 2005 1:16 am
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);
shiznatix
DevNet Master
Posts: 2745 Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:
Post
by shiznatix » Sun Jan 30, 2005 1:33 am
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