Hello There.
My name is Andreas.
Well I have begin coding and come to the part at my menu where the username should be in my menu.
I have a login form and it look like this:
<?php
session_start();
$username = $_POST['username'];
$password = $_POST['password'];
if ($username&&$password)
{
$connect = mysql_connect("localhost","root","") or die ("Could not connect to MySQL Host");
mysql_select_db("host") or die ("Cound not find MySQL Database");
$query = mysql_query("SELECT * FROM users WHERE username='$username'");
$numrows = mysql_num_rows($query);
if($numrows !=0)
{
while ($row = mysql_fetch_assoc($query))
{
$dbusername = $row['username'];
$dbpassword = $row['password'];
}
if ($username==$dbusername&&$password==$dbpassword)
{
header ("Location: http://localhost/Host/index.php");
$_SESSION['username']=$dbusername;
}
else
echo "Incorrect password";
}
else
die ("That username does not exists");
}
else
die ("Please enter a username");
?>
But when I use this php code in my menu:
<?php
if ($_SESSION['username'])
{
echo "<li><a href='#'><span>$_SESSION['username'];</span></a>
<ul>
<li><a href='client/account/logout.php'><span>Logout</span></a></li>
<li><a href='client/account/profile.php'><span>Profile</span></a></li>
</ul>
</li>";
}
?>
But i get a error in the session section and I know its something with the $_session code.
But I dont know what to type in between the <span> and </span>.
This is the image I get in Adobe DreamWeaver: