Hello,
I am trying to create a members page for my website and I want it to display a welcome message for when the person views it, something like:
"Welcome <USERNAME>"
I am new to PHP so I am not sure if there is something I am doing wrong, here is what I have so far:
For the Login Page
<?php
session_start();
$Connection = mysql_connect("localhost","root","password") or die ("Login Fail");
mysql_select_db("database") or die ("Cannot Find DB");
if(isset($_SESSION['Logged']))
{
die(header ('Location: ../Pages/Members.php'));
}
$Username = strip_tags(strtolower($_POST['Username']));
$Password = strip_tags(md5($_POST['Password']));
$mysql = mysql_query("SELECT * FROM Member_Data WHERE Username = '$Username' AND Password = '$Password'");
if(mysql_num_rows($mysql) < 1)
{
die(header('Location: Errors/Password.php'));
}
$_SESSION['Logged'] = "YES";
$_SESSION['Username'] = $Username;
die(header('Location: ../Pages/Members.php'));
?>
(I have removed my password and DB name from the code for safety reasons, but I know for a fact these are correct).
And this is the part for displaying the message:
<?php
session_start();
{
echo $_SESSION['Username'] or die (mysql_error());
}
?>
When I try and echo it out, all I get is 'Welcome 1'.
Originally I thought this was the ID in the database, because I was the first account I had that ID but when creating another account I still get the same message.
Please could someone tell me what I am doing wrong and how to fix it, thanks!