JBZonda / educom-webshop-database

0 stars 0 forks source link

Maak om het menu te maken gebruik van session_functions #16

Open JeroenHeemskerk opened 1 year ago

JeroenHeemskerk commented 1 year ago

https://github.com/JBZonda/educom-webshop-database/blob/0af35f67402eb5aa86e7c38cff70409f09677160/html_build_functions.php#L22-L40

De code hierboven maakt gebruik van de $_SESSION variabele, het is beter om dat in een functie in session_functions.php te zetten zodat je hier kan doen:

function showNavbar($data){ 
     echo '<div id="nav_bar"> 
     <ul> 
         <li> <a href="\educom-webshop-database/index.php?page=home">Home</a></li> 
         <li> <a href="\educom-webshop-database/index.php?page=about">About</a></li> 
         <li> <a href="\educom-webshop-database/index.php?page=contact">Contact</a></li>'; 

     #show a register and login or a loguit option depending on if the user is loged in 
     if (isUserLoggedIn()){ 
         echo '<li> <a href="\educom-webshop-database/index.php?page=register">Registeer</a></li> 
         <li> <a href="\educom-webshop-database/index.php?page=login">Login</a></li>'; 
     } else { 
         echo 
         '<li><a href="\educom-webshop-database/index.php?page=logout">Loguit ' . getLoggedInUserName() . '</a></li> 
         <li><a href="\educom-webshop-database/index.php?page=change_password">Wachtwoord veranderen</a></li>'; 
     } 
     echo '</ul> 
     </div>'; 
 }