knifeh Posted February 17, 2010 Share Posted February 17, 2010 Hi guys im kinda new to php so im probably struggling on the most basic thing in the world, anyways i've coded and index.php so that when a user is not logged in it shows a table with text saying not logged in, only problem is. is that the table and text arent showing. <?php require_once('function.php'); connect(); $sesuser = $_SESSION['username']; if(loggedin()) { if(isset($_SESSION['username'])){ $sesuser = $_SESSION['username']; }else { $sesuser = $_COOKIE['username']; } $query4 = mysql_query("SELECT * FROM users WHERE username='$sesuser'"); while($rowrow = mysql_fetch_assoc($query4)){ $admin = $rowrow['admin']; } if($admin){ header('location: admin.php'); } else if(!$admin){ echo "Welcome back $sesuser"; } else if(!logged_in()) ?> <html> <link href="style/main.css" rel="stylesheet" type="text/css" /> <body> <table width="68%" border="1" align="center"> <tr> <td height="74" colspan="3"> </td> </tr> <tr> <td colspan="3" height="30"> <?php { echo "You are not logged in! <a href='login.php'>Click here to login</a><br>"; echo "Or if you are not registered and wish to do so, please <a href='register.php'>click here</a>"; ?> </td> </tr> <tr> <td height="347" colspan="3"> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> <?php } } ?> </table> </body> </html> i really have no idea what i've done wrong any help would be appreciated!! Thanks in advance guys Luke Quote Link to comment https://forums.phpfreaks.com/topic/192405-not-displaying-table/ Share on other sites More sharing options...
premiso Posted February 17, 2010 Share Posted February 17, 2010 It is because you have your table code in a bad spot, that could be causing a syntax error. } else if(!logged_in()) { //note that I moved the brace up here where it should be ?> <html> <link href="style/main.css" rel="stylesheet" type="text/css" /> <body> <table width="68%" border="1" align="center"> <tr> <td height="74" colspan="3"> </td> </tr> <tr> <td colspan="3" height="30"> <?php echo "You are not logged in! <a href='login.php'>Click here to login</a><br>"; echo "Or if you are not registered and wish to do so, please <a href='register.php'>click here</a>"; ?> Not sure if that is what you were trying to achieve, but yea. That will display your table if the user is not logged in. Quote Link to comment https://forums.phpfreaks.com/topic/192405-not-displaying-table/#findComment-1013805 Share on other sites More sharing options...
knifeh Posted February 17, 2010 Author Share Posted February 17, 2010 hey premiso, thanks for the response but i moved the brace as you said but its still not showing the table, any other ideas dude? Quote Link to comment https://forums.phpfreaks.com/topic/192405-not-displaying-table/#findComment-1013812 Share on other sites More sharing options...
Vivid Lust Posted February 17, 2010 Share Posted February 17, 2010 add session_start(); to the top of the script Quote Link to comment https://forums.phpfreaks.com/topic/192405-not-displaying-table/#findComment-1013814 Share on other sites More sharing options...
knifeh Posted February 17, 2010 Author Share Posted February 17, 2010 hey man i added the session_start(); but its still not showing the table maybe ive just complete messed the code up somewhere lol. might just rewritten the whole thing. cheers tho guys! Quote Link to comment https://forums.phpfreaks.com/topic/192405-not-displaying-table/#findComment-1013820 Share on other sites More sharing options...
Vivid Lust Posted February 17, 2010 Share Posted February 17, 2010 Could we see functions.php? Quote Link to comment https://forums.phpfreaks.com/topic/192405-not-displaying-table/#findComment-1013844 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.