将会话中的值输出到表单中

I am having some problem with trying to output 2 session values. It works fine when i output only the $_SESSION['mypassword']="myusername";

But then i try to output two session values, it does not work. Here is an example of what I have done so far.

<?php
session_start();


$_SESSION['mypassword']="myusername";
$_SESSION['studentid']="studentid";
echo "Logged in as".$_SESSION['studentid'];
echo "<h3 class='velkommen'>Logga inn som:<span class='spanclass'>" .$_SESSION['myusername']. "</span></h3>";

?>

The studentid output as studentid. The page before i did this:

// username and password sent from form 
$myusername=$_POST['myusername']; 
$mypassword=$_POST['mypassword'];
$studentid=$_POST['studentid'];

// To protect MySQL injection (more detail about MySQL injection)
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$studentid = stripslashes($studentid);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
$studentid = mysql_real_escape_string($studentid);
$sql="SELECT * FROM $tbl_name WHERE myusername='$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){

$_SESSION['myusername'] = $myusername;
$_SESSION['mypassword'] = $mypassword;
$_SESSION['studentid'] = $studentid;
header("location:login_success.php" );

Any tip why it only the myusername who is correct? I need the both values to be in a form

<?php
    echo '<input type="hidden" name="myusername" value="'.$_SESSION['myusername'].'">';
?>

Any tip?

Try this:

   <?php
    session_start();
    $_SESSION['mypassword']="myusername";
        $_SESSION['studentid']="studentid";
        echo "Logged in as".$_SESSION['studentid'];
        echo "<h3 class='velkommen'>Logga inn som:<span class='spanclass'>". $_SESSION['mypassword'] . "</span></h3>";
    ?>

You are setting a session for mypassword

$_SESSION['mypassword']="myusername";
$_SESSION['studentid']="studentid";

whereas you are doing an echo for $_SESSION['myusername']

echo "<h3 class='velkommen'>Logga inn som:<span class='spanclass'>" .$_SESSION['myusername']. "</span></h3>";

I dont see any $_SESSION['myusername']

What you need to do is, this

$_SESSION['myusername']="myusername";
$_SESSION['studentid']="studentid";

echo "Logged in as: ".$_SESSION['studentid'];

    echo "<h3 class='velkommen'>Logga inn som:<span class='spanclass'>" .$_SESSION['myusername']. "</span></h3>";