<center><input type="submit" value="Login" name="submit"></center><p>
</form>
<?
}elseif(session_is_registered('s_username')){
include('includes/connect.htm');
$query = mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error());
$data = mysql_fetch_array($query);
if($data['userlevel'] != "1")
{
die("<center><h3>You are not a admin.</h3></center>");
}else{
?>
//webpage here
<?
}
}
?>
It is not working, it is supposed to do the following, if you are not loged in already, it gives you a login form, which when submited is supposed to check against the database, to see wether or not your information is correct, if it is, it sets a session variable with your name in it, and re-directs you to the same page, which will then have you showing as loged in, so the webpage within will show. If, However, you are already loged in, it will simply check your user level from the database. But, the problem is, is that this is doing nothing, i submit it, and it redirects back to the same page, but i still am being shown the login form, please help. Thanks.
HTML skill level: Good
Javascript skill level: somewhere between poor and good
php: good but still getting better
sql: good but still getting better
Most important is that you need a session_start(); at the beginning of the script. Secondly, you should not use session_is_registered() in combination with $_SESSION. Instead, just do if(isset($_SESSION['s_username'])).
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
sorry, i knew about that, i just wasn't thinking. Also, it is actually giving me a response now, but its the you are not a admin message, which as i'm looking at the table right now, I do in fact have a user level of one, so why isn't this working? I have the table column right, and I added a bit which echo's out the username that it's checking on, and it is the user which has a userlevel of 1. So I'm not sure why this isn't working.
HTML skill level: Good
Javascript skill level: somewhere between poor and good
php: good but still getting better
sql: good but still getting better
Bookmarks