Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 06-11-2006, 10:26 AM if()
Experienced Talker

Posts: 41
Trades: 0
look at this code..

PHP Code:
<?php if($level == 0){?>
<tr>
<td colspan="3"><div align="center">This page contain adult content, and should only be view be people 18 or older.<br />
are you 18 or older?
<form method="post" action="<?php $_SERVER['PHP_SELF']?>" name="yf"><label>
<input type="submit" name="Submit" value="yes" />
</label>
</form>
by clicking yes, you agree to be 18 years of age or older.

<?php if(isset($_POST['Submit'])){
$query=mysql_query("UPDATE tra_users SET level='1' WHERE username='$username'")or die(mysql_error);
}
?>

<?php
}elseif($level >= 1){
echo 
"blah"
//$level is passed on by $_SESSION
?>
it works fine the only problem is that it does change from 0 to 1 in the database, but when i echo out the user level it echos out 0 and acts as if the user is on level zero even when in the database is not zero..
richard181 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-11-2006, 02:09 PM Re: if()
AliKat's Avatar
Extreme Talker

Latest Blog Post:
Save the Children
Posts: 176
Location: MS
Trades: 0
where are you getting $level from?
AliKat is offline
Reply With Quote
View Public Profile Visit AliKat's homepage!
 
Old 06-11-2006, 04:29 PM Re: if()
Experienced Talker

Posts: 41
Trades: 0
it says it $level is coming from $_session.. wich is passed to every ppage but what i need to do is refresh the user session.. how do i send the user to a page and get the url of that page and send him back to it?
richard181 is offline
Reply With Quote
View Public Profile
 
Old 06-12-2006, 09:04 AM Re: if()
AliKat's Avatar
Extreme Talker

Latest Blog Post:
Save the Children
Posts: 176
Location: MS
Trades: 0
Did you ever change $_SESSION[level] (assumping that's that variable) or do you ever grab it from the database before using your if statements?

You either need to mannual change your session variable or make sure to call it from the database

You will probably need to check the $_SERVER variables. I think there is a referer one in there.

http://us3.php.net/manual/en/reserve...riables.server - a link of the server variables
AliKat is offline
Reply With Quote
View Public Profile Visit AliKat's homepage!
 
Old 06-12-2006, 11:00 AM Re: if()
Experienced Talker

Posts: 41
Trades: 0
yeah everything works fine i just need a way to refresh the session.. because only works if i destroy the session and start it again..
richard181 is offline
Reply With Quote
View Public Profile
 
Old 06-12-2006, 02:46 PM Re: if()
AliKat's Avatar
Extreme Talker

Latest Blog Post:
Save the Children
Posts: 176
Location: MS
Trades: 0
Since I don't know what is before the snipet you posted it's hard to tell what's going on. But try this:

<?php if(isset($_POST['Submit'])){
$query=mysql_query("UPDATE tra_users SET level='1' WHERE username='$username'")or die(mysql_error);
$_SESSION[level] = '1'; //or whatever your session variable is.
}?>

Since I don't know what follows I can't see if you have stuff following it. And how the page is going to refresh itself.

The session change won't happen unless you've not printed any html etc to the browser. But it should happen on refresh.
AliKat is offline
Reply With Quote
View Public Profile Visit AliKat's homepage!
 
Reply     « Reply to if()
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.78408 seconds with 12 queries