page is not processed if content is in a while loop
<pre><code>&lt;?php 
include("global-settings.php"); 
session_start(); 
mysql_connect($dbhost, $dbuser, $dbpass)or die("Could Not Connect: " . mysql_error()); 
mysql_select_db($dbname) or die(mysql_error()); 
$email       = mysql_real_escape_string(strip_tags($_POST['email'])); 
$password  = mysql_real_escape_string(strip_tags(sha1($_POST['password']))); 

$result  = mysql_query("SELECT * FROM users WHERE username='$email' AND password='$password'") or die(mysql_error()); 

    while($row = mysql_fetch_array($result)) {
    if(mysql_num_rows($result) &gt; 0) { 
        $_SESSION['user_pid']    = $row['user_pid']; 
        $_SESSION['firstname']     = $row['first_name']; 
        $_SESSION['lastname']     = $row['last_name']; 
        header("Location: ../protected/home.php"); 
    } else {
        $userid_generator = uniqid(rand(), false); 
        $date = date("Y/m/d"); 
        mysql_query("INSERT INTO users (user_pid, username, password, datetime_registered) 
        VALUES('$userid_generator', '$email', '$password', '$date')")or die(mysql_error()); 
        $_SESSION['userid']    = $userid_generator; 
        $_SESSION['firstname']     = $row['first_name']; 
        $_SESSION['lastname']     = $row['last_name']; 

        $leaders_query = "SELECT * FROM leaders"; 
        $leaders   = mysql_query($leaders_query); 

            $id = $row['id']; 
            mysql_query("INSERT IGNORE INTO friends (node1id, node2id, is_leader, friends_since, friend_type) 
            VALUES('$id', '$userid_generator', 'Yes', '$date', 'full)")or die(mysql_error());     
    }
        }
?&gt;
</code></pre>

<p>for some reason the while loop doesn't seem to work. It leaves a blank screen when I insert the content inside the while loop. Any help?</p>
