Note that there are some explanatory texts on larger screens.

plurals
  1. POChanging an output for a link in php
    text
    copied!<p>I'm trying to get a link in my menu to change once the user logged in. Meaning that "My Page" is displayed, rather than "Log In". Now, the user can log in and log out. Yet the name/link will not change directly after the user logged in.</p> <p>My code for the menu: (I use include('menu.php' on all sites. For flexibility of the code) </p> <pre><code>&lt;div id="menu"&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="index.php"&gt;Home&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;?php echo $mypage?&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="community.html"&gt;Community&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="media.html"&gt;Media&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="contact.html"&gt;Contact&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; </code></pre> <p></p> <p>My code for the config.php:</p> <pre><code>&lt;?php session_start(); $mypage; if(isset($_SESSION['name'])) { $mypage = '&lt;a href="mypage.php"&gt;My Page&lt;/a&gt;'; } else { $mypage = '&lt;a href="login.php"&gt;Log In&lt;/a&gt;'; } ?&gt; </code></pre> <p>Only when the user clicks on another menu the $mypage variable will update. I've tried refreshing the page with a header() function. But this only lead into a redirection-loop.</p> <p>It would be great if someone could help me out.</p> <p><strong>EDIT</strong></p> <p>To clear some things up:</p> <p>For a better understanding of the website: <a href="http://askmephilosophy.camilstaps.nl/" rel="nofollow">http://www.askmephilosophy.camilstaps.nl/</a> (The only thing that can be viewed (so far) are the 'Welcome' and 'Log In'. After a login you will be redirected to a mypage.php site. (this can also be accessed by just typing it after the name. */mypage.php)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload