0

I am building my login system for my website, everything is working as intended however I wanted to further design a feature where if the user is logged in, echo their name with a 'Manage' bit of text before it, so ideally they would login, this new button would appear that says Manage | 'Their username'. I have managed to implement a changing 'logout/login' button so when they are logged in, 'logout' will appear and vice versa in the code below.

login change

                <?php if(isset($_SESSION['user_id']) || 
isset($_SESSION['logged in'])){ ?>
            <li> <a href="logout.php"> Logout |  <?php echo 
$_SESSION['user_id'] ?> </a></li>
            <?php }else{ ?>
            <li> <a href="loginpage.php" >login</a></li>
                <?php } ?>

This is at the top of my navbar, I have tried to apply the same principle however the page just becomes unresponsive. After adding and removing code when I only implement this section

<li> <a href="clubpage.php"> Manage |  <?php echo $_SESSION['user_id'] ?> 
</a></li>

It displays as intended, however then when attempting to create an if statement (so when no one is logged in nothing is displayed) That's when the page dies for example

<?php if(isset($_SESSION['user_id']) || isset($_SESSION['logged in'])){ ?> //   etc

Now I imagine It's an issue with the if statement, which I am calling further down obviously to change the login. Any help where I'm going wrong would be helpful, thanks in advance Error log

[03-Aug-2018 22:43:44 UTC] PHP Parse error:  syntax error, unexpected end of 
file in C:\Users\b\Desktop\code\clubpage.php on line 39

 <body>
<div class ="container">
    <header> <a href=""></a>
        <h4 class="logo"> Game Finder </h4>
    </a>
    <nav>
        <ul>
    <?php if(isset($_SESSION['user_id']) || isset($_SESSION['logged in'])){ ?>
    <li> <a href="clubpage.php"> Manage |  <?php echo $_SESSION['user_id'] ?> </a></li>
            <li> <a href="/index.php">Home</a></li>
            <li> <a href="#about"> About</a></li>
            <li> <a href="/finder.php"> Finder </a></li>
            <?php if(isset($_SESSION['user_id']) || isset($_SESSION['logged in'])){ ?>
            <li> <a href="logout.php"> Logout |  <?php echo $_SESSION['user_id'] ?> </a></li>
            <?php }else{ ?>
            <li> <a href="loginpage.php" >login</a></li>
                <?php } ?>
        </ul>
    </nav>
</header>

Isaac
  • 784
  • 10
  • 23
  • *"That's when the page dies"* - Can you be more specific? Have you turned on error reporting, checked the PHP error logs, etc.? – David Aug 03 '18 at 21:38
  • 'localhost is unable to handle this request HTTP error 500' I will look into the error logs now, sorry for not including that, been a longg day. – Isaac Aug 03 '18 at 21:39
  • @David thanks for the response but I fixed it! :D – Isaac Aug 03 '18 at 22:17

1 Answers1

0

I have found and fixed the issue! was a combination of two things, Simple really I had a syntax error where I wasn't closing the else part of the if statement here below index.php

      <?php }else{ ?>
    <li> <a href="/index.php"> ff </a></li>
    <?php } ?>

Additionally this didn't fix it straight away, I read this Answer Here Which helped me change a setting in my php.ini file which fixed the issue! thanks anyway guys!

Isaac
  • 784
  • 10
  • 23