New session login script not working in PHP
<p>I am using this script see below, which I got from this site to login users and redirect  to a webpage based on their login. It works great but I am having trouble pulling the username into the page they are redirected to. The new session script below usually works with simple scripts but it does not appear to work with this redirect script. If someone could point me in the right direction I would be grateful as I am very new to PHP, this is my first attempt. Thanks Alan</p>

<p>Redirect script works great.</p>

<pre><code>&lt;?php 
$host="localhost"; // Host name 
$username=""; // Mysql username 
$password=""; // Mysql password 
$db_name="trydata"; // Database name 
$tbl_name="users"; // Table name

mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB"); 
// username and password sent from form 
$myusername=$_POST['username']; 
$mypassword=$_POST['password']; 

// 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"login_success.php" 
    $_SESSION['username'] = $myusername; 
    $_SESSION['password'] = $mypassword; 

    $result = mysql_fetch_array($result); // get the result set from the query

    $redirect = trim($result['redirect']); // get the redirect column's value

    if ($redirect == '') {
        echo "No redirect value was set!";
    } else {
        header('Location: ' . $redirect);
        exit;
    }
} else { 
    echo "Wrong Username or Password"; 
} 

?&gt;

New session script not pulling loin information through.

&lt;?php 
session_start(); // start up your PHP session! 


if (isset($_SESSION['username'])
{

    echo "You are logged in as ".$_SESSION['username'];
    echo "&lt;p&gt;";

    echo "&lt;a href='logout.php'&gt; Click here to logout&lt;a/&gt;";
    }

else

header ("Location: form.php");

?&gt;
</code></pre>
