I'm completely new to PHP. So yeah this code might totally make no sense. But anways. I want to ask for help. If someone can tell me what is wrong and or just write correct code.
Basicly what i try make code to do is check if user is logged in, if not then show he login and register link.
If he is logged in then show him his username.
Here is PHP code:
<?php
require("common.php");
if(empty($_SESSION['user']))
{
echo("<a href="login.html"><b>Login</b></a>");
echo("<a>or<a>");
echo("<a href="register.html"><b>Register</b></a>");
}
else
{
echo 'Username: ' . $current_user->user_login . "\n";
}
?>
Code from HTML:(Code that i use to include this code. Not sure if its also...)
<header action="php/check.php" method="post">
Thanks for answers Still not working tho :( Here is current code, I edited how you guys adviced.
<?php
session_start()
require("common.php");
if(empty($_SESSION['user']))
{
echo '<a href="login.html"><b>Login</b></a>';
echo '<a>or<a>';
echo '<a href="register.html"><b>Register</b></a>';
}
else
{
echo 'Username: ' . $current_user->username . "\n";
}
?>