Jump to content

PHPAndreas

New Members
  • Posts

    2
  • Joined

  • Last visited

PHPAndreas's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks alot! It worked
  2. 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:
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.