I have a subdomain
accounts.mysite.com
What i want is one login panel for that subdomain, then after a user logs in it directs them to their own page (and
Include a file at the top of every file that should be blocked that contains something like:
<?php
if (isset($_SESSION['user_id']) && $_SESSION['user_id']) {
header('Location: user.php?id=' . $_SESSION['user_id']);
exit;
}
This will redirect the user to user.php everytime they try to visit another file.
Edit: And don't forget to use session_start() at the beginning of every request.
Your code looks bad.
session_register("myusername"); - This function has been DEPRECATED as of PHP 5.3.0.
Move your database config to another file.
$host="localhost"; // Host name
$username="******"; // Mysql username
$password="*******"; // Mysql password
$db_name="medpro_test"; // Database name
$tbl_name="members"; // Table name
Use header location http://php.net/manual/en/function.header.php to move user to the link.