Redirect after PHP Login
<p>I have a subdomain </p>

<p>accounts.mysite.com </p>

<p>What i want is one login panel for that subdomain, then after a user logs in it directs them to their own page (and stops them from viewing 'other account' pages). </p>

<p>So when they go to accounts.mysite.com that is the login page. User logs in using specific name, pass. After successful login directed to their accounts page but blocks all other pages. </p>

<p>Here is what I have so far </p>

<pre><code>&lt;?php
ob_start();
$host="localhost"; // Host name
$username="******"; // Mysql username
$password="*******"; // Mysql password
$db_name="medpro_test"; // Database name
$tbl_name="members"; // Table name

// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

// Define $myusername and $mypassword 
$myusername=$_POST['myusername']; 
$mypassword=$_POST['mypassword']; 

// To protect MySQL injection (more detail about MySQL injection)
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);

$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);

// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row

if($count==1){
// Register $myusername, $mypassword and redirect to file 
session_register("myusername");
session_register("mypassword"); 
header('Location: user.php?id=' . $_SESSION['user_id']); 
}

else {
$result = MYSQL_QUERY($sql) or die('Query failed: ' . mysql_error() . "&lt;br /&gt;\n$sql");
echo "Wrong Username or Password";
}

ob_end_flush();
?&gt;
</code></pre>

<p>I am a noob so any help would be appreciated!</p>
