So far, I have managed to create a register, login and welcome page with PHP. I'm now focusing on a creating a profile page. I'm wondering, first of all, how I can have every page on my site display "Welcome, " .$username. Do I have to insert a cookie write session_start(); on top of each page to do that, or is there an easier way?
And for the actual profile page, how can I make it display data from the database? I know it's fairly simple, but it doesn't work so far. I've tried something really simple, but lines 8, 10 and 14 are off. Thanks a lot for any help
BASICALLY, I'm asking how I can fetch data from my table just for the user that's logged in and display it.
<?php
session_start();
$link = mysql_connect('localhost','root','1234') or die('Cant connect to database');
mysql_select_db('youtube');
$username=$_COOKIE['username'];
$username=$_COOKIE['password'];
$query = mysql_query("SELECT username FROM user WHERE username='$username'
AND password='$password'")
or die(mysql_error());
echo "Welcome, " . $username . ".";
echo $email;
//echo a bunch of other stuff, such as the user's age, real name and so forth
if (!isset($_SESSION['username']))
{
header('location: login.php');
}
?>