Sorry if this is a dumb question but I'm quite a beginner in php and I really don't know how to deal with this. I created a simple login system on my website (login.php), containing variables username and password. This works pretty fine but I got another page called forum (forum.php) and I want the username from login.php to be displayed in the forum.php (instead of the 'Anonymous' value that I temporarily put there) when the user is logged in, as well. And I also would like to have the username displayed through all of the pages of the website. Do you please have any advice how to do that? I can't really use the form action attribute for the forum.php because I used a submitting function there. Thank you all a lot!
This is my forum code:
<?php
echo "<form method='POST' action='".setComments($conn)."'>
<input type='hidden' name='name' value='Anonymous'>
<input type='hidden' name='date' value='".date('Y-m-d | H:i:s')."'>
<textarea name='message' cols='30' rows='10'></textarea><br>
<input type='submit' name='submitComment' value='Submit'><br>
</form>";
getComments($conn);
?>