-1

I am making a user login form for my website and this error pops up Error Message my code is:

<?php if( isset($user) ): ?>

    <br />Welcome <?= $user['username']; ?>
    <br /><br />You are successfully logged in!
    <br /><br />
    <a href="logout.php">Logout?</a>

<?php else: ?>

<h1>Please Login or Regester</h1>
<a href="login.php">Login</a> or
<a href="register.php">Register</a>

<?php endif; ?>

can someone help me if I need to provide anymore code i will do so to fix this error

PMCJohn
  • 136
  • 1
  • 2
  • 9

2 Answers2

0

try using this

<?php if(isset($user['username'])){echo $user['username'];} else{ echo 'Guest';} ?>
  • working somewhat but i need to edit the code a little bit to get the else that i want. I added the peripherals of the code to get more useful responces – PMCJohn Dec 30 '15 at 08:06
0

@Vegeta fixed my problem with:

instead of if( isset($user) use if( isset($user['username'])

website works now

PMCJohn
  • 136
  • 1
  • 2
  • 9