DeanWhitehouse Posted April 21, 2008 Share Posted April 21, 2008 <?php if ($_SESSION['is_valid'] == true){ if ($_SESSION['user_level'] == 2){ mysql_query("SELECT * from `$user` WHERE user_name"); echo "<table class='logged_in'><tr><td> Welcome $user_name,<br> <a href=''>User Profile</a><br> <a href=''>Settings</a> <a href='logout.php'>Logout</a> </td></tr><tr><td><font color='white'>Logged In</font></td></tr></table>"; } if ($_SESSION['user_level'] == 1){ mysql_query("SELECT * from `$user` WHERE user_name"); echo "<table class='logged_in'><tr><td> Welcome $user_name,<br> <a href=''>User Profile</a><br> <a href=''>Settings</a> <a href='logout.php'>Logout</a> </td></tr><tr><td><font color='white'>Logged In</font></td></tr></table>"; } else { include_once'login.php'; } } ?> this code is ment to display a login form if the user is not logged in, but it doesn't, and i dunno why Quote Link to comment Share on other sites More sharing options...
DarkWater Posted April 21, 2008 Share Posted April 21, 2008 Dude. Stop using these `````` quotes on the queries. >_> Quote Link to comment Share on other sites More sharing options...
Fadion Posted April 21, 2008 Share Posted April 21, 2008 Shouldnt a normal query be: "SELECT * FROM users WHERE username='$user_name'"; ??? Quote Link to comment Share on other sites More sharing options...
DeanWhitehouse Posted April 21, 2008 Author Share Posted April 21, 2008 the table name is saved as a variable, so no to "SELECT * FROM users and i want to display the users username, but i can't think of a way to. Anyway back to the main problem, of the login page not displaying Quote Link to comment Share on other sites More sharing options...
DarkWater Posted April 21, 2008 Share Posted April 21, 2008 Yeah, Guiltygear is right. Your WHERE statement is messed up too. Quote Link to comment Share on other sites More sharing options...
DeanWhitehouse Posted April 21, 2008 Author Share Posted April 21, 2008 ok, people ignore the sql statement, Quote Link to comment Share on other sites More sharing options...
DarkWater Posted April 21, 2008 Share Posted April 21, 2008 I see the problem. The last lines look like this: else { include_once'login.php'; } } Should be: } else { include_once ('login.php'); } So that the else statement applies to the if ($_SESSION['is_valid'] == true){ conditional. =) And the include should be: include_once ('login.php'); Not: include_once'login.php'; Quote Link to comment Share on other sites More sharing options...
DeanWhitehouse Posted April 21, 2008 Author Share Posted April 21, 2008 when i remove the curly bracket i get this error Parse error: syntax error, unexpected $end in /home/www/deanwhitehouse.awardspace.co.uk/logged_in.php on line 26 and you can write includes and requires without the brackets Quote Link to comment Share on other sites More sharing options...
redarrow Posted April 21, 2008 Share Posted April 21, 2008 Do you mean this? <?php session_start(); if ($_SESSION['is_valid'] == true){ if ( ($_SESSION['user_level'] == 1) || ($_SESSION['user_level2'] == 2) ){ mysql_query("SELECT * from `$user` WHERE user_name='$user_name'"); echo "<table class='logged_in'><tr><td> Welcome $user_name,<br> <a href=''>User Profile</a><br> <a href=''>Settings</a> <a href='logout.php'>Logout</a> </td></tr><tr><td><font color='white'>Logged In</font></td></tr></table>"; }else{ include_once'login.php'; } } ?> Quote Link to comment Share on other sites More sharing options...
DarkWater Posted April 21, 2008 Share Posted April 21, 2008 when i remove the curly bracket i get this error Parse error: syntax error, unexpected $end in /home/www/deanwhitehouse.awardspace.co.uk/logged_in.php on line 26 and you can write includes and requires without the brackets You missed what I said. Move the last } to right above the else block. >_> Copy and paste exactly what I put. =/ Quote Link to comment Share on other sites More sharing options...
DeanWhitehouse Posted April 21, 2008 Author Share Posted April 21, 2008 ok, thanks, this is now my working code <?php require_once 'includes/config_table.inc.php'; require_once 'includes/db_connect.php'; mysql_query("SELECT * from `$user` WHERE user_name='$user_name'"); if ($_SESSION['is_valid'] == true){ if ($_SESSION['user_level'] == 2){ echo "<table class='logged_in'><tr><td> Welcome $user_name,<br> <a href=''>User Profile</a><br> <a href=''>Settings</a> <a href='logout.php'>Logout</a> </td></tr><tr><td><font color='white'>Logged In</font></td></tr></table>"; } if ($_SESSION['user_level'] == 1){ echo "<table class='logged_in'><tr><td> Welcome $user_name,<br> <a href=''>User Profile</a><br> <a href=''>Settings</a> <a href='logout.php'>Logout</a> </td></tr><tr><td><font color='white'>Logged In</font></td></tr></table>"; } } else { include_once ('login.php'); } ?> how can i display the user name of the user, i am using sessions and cookies Quote Link to comment Share on other sites More sharing options...
iarp Posted April 21, 2008 Share Posted April 21, 2008 <?php echo $_SESSION['user_name']; ?> Quote Link to comment Share on other sites More sharing options...
DeanWhitehouse Posted April 21, 2008 Author Share Posted April 21, 2008 ok, thanks for all the help. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.