wezze Posted June 19, 2012 Share Posted June 19, 2012 Hi im trying to get this into an include <?php /*********************** MYACCOUNT MENU **************************** This code shows my account menu only to logged in users. Copy this code till END and place it in a new html or php where you want to show myaccount options. This is only visible to logged in users *******************************************************************/ if (isset($_SESSION['user_id'])) {?> <div class="myaccount"> <p><strong>My Account</strong></p> [<a href="myaccount.php">My Account</a>]<br> [<a href="mysettings.php">Settings</a>]<br> [<a href="../filmen_leden.php">Filmen</a>]<br> [<a href="logout.php">Logout </a>] <p></p></div> <p> </p> <p> </p> <p> </p> <?php } if (checkAdmin()) { /*******************************END**************************/ ?> <p> [<a href="admin.php">Admin CP </a>]</p> <?php } ?> [<a href="../links.php">links</a>]<br> [<a href="../gastenboek/admin/index.php">Gastenboek</a>]<br> [<a href="../livre d'or/admin/index.php">livre d'or</a>]<br> [<a href="../upload_kalender/upload.form.php">upload kalender</a>]<br> </td> but it doesnt show in my side menu this is the original code <table width="100%" border="0" cellspacing="0" cellpadding="5" class="main"> <tr> <td colspan="3"> </td> </tr> <tr> <td width="160" valign="top"> <?php /*********************** MYACCOUNT MENU **************************** This code shows my account menu only to logged in users. Copy this code till END and place it in a new html or php where you want to show myaccount options. This is only visible to logged in users *******************************************************************/ if (isset($_SESSION['user_id'])) {?> <div class="myaccount"> <p><strong>My Account</strong></p> [<a href="myaccount.php">My Account</a>]<br> [<a href="mysettings.php">Settings</a>]<br> [<a href="../filmen_leden.php">Filmen</a>]<br> [<a href="logout.php">Logout </a>] <p></p></div> <p> </p> <p> </p> <p> </p> <?php } if (checkAdmin()) { /*******************************END**************************/ ?> <p> [<a href="admin.php">Admin CP </a>]</p> <?php } ?> [<a href="../links.php">links</a>]<br> [<a href="../gastenboek/admin/index.php">Gastenboek</a>]<br> [<a href="../livre d'or/admin/index.php">livre d'or</a>]<br> [<a href="../upload_kalender/upload.form.php">upload kalender</a>]<br> </td> <td width="732" valign="top"><p> </p> <h3 class="titlehdr">Welcome <?php echo $_SESSION['user_name'];?></h3> <?php if (isset($_GET['msg'])) { echo "<div class=\"error\">$_GET[msg]</div>"; } ?> <p>This is the my account page</p> </td> <td width="196" valign="top"> </td> </tr> <tr> <td colspan="3"> </td> </tr> </table> any ideas? thx Quote Link to comment https://forums.phpfreaks.com/topic/264453-php-includes-side-menu-help/ Share on other sites More sharing options...
Mahngiel Posted June 19, 2012 Share Posted June 19, 2012 the only answer is your session[user_id] is not set. Also, to help you keep track of your conditionals and loops, you can break them up with colons instead of brackets. <?php if( condition ): ?> html code <?php endif; ?> Quote Link to comment https://forums.phpfreaks.com/topic/264453-php-includes-side-menu-help/#findComment-1355232 Share on other sites More sharing options...
wezze Posted June 19, 2012 Author Share Posted June 19, 2012 what do you mean with session[user_id] is not set? <?php <?php if( isset($_SESSION['user_id'] ): ?> <p><strong>My Account</strong></p> [<a href="myaccount.php">My Account</a>]<br> [<a href="mysettings.php">Settings</a>]<br> [<a href="../filmen_leden.php">Filmen</a>]<br> <p> </p> [<a href="logout.php">Logout </a>] <p> </p> <p> </p> <p> </p> <?php endif; ?> <?php if( checkAdmin ): ?> <p>[<a href="admin.php">Admin CP </a>]</p> [<a href="../links.php">links</a>]<br></li> [<a href="../gastenboek/admin/index.php">Gastenboek</a>]<br> [<a href="../livre d'or/admin/index.php">livre d'or</a>]<br> [<a href="../upload_kalender/upload.form.php">upload kalender</a>]<br> <?php endif; ?> is this what you mean with the conditionals and loops? thx Quote Link to comment https://forums.phpfreaks.com/topic/264453-php-includes-side-menu-help/#findComment-1355234 Share on other sites More sharing options...
Mahngiel Posted June 19, 2012 Share Posted June 19, 2012 what do you mean with session[user_id] is not set? Your condition checks to see if the $_SESSION key user_id is set, and if so, permits the output of that code. If the code is not being output, it is because the isset failed. is this what you mean with the conditionals and loops? Yes it is. Much easier to read, isn't it? Quote Link to comment https://forums.phpfreaks.com/topic/264453-php-includes-side-menu-help/#findComment-1355242 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.