Index: trunk/ippMonitor/raw/ipp.php
===================================================================
--- trunk/ippMonitor/raw/ipp.php	(revision 13566)
+++ trunk/ippMonitor/raw/ipp.php	(revision 13595)
@@ -9,7 +9,11 @@
 }
 
-function loginform () { 
+function loginform ($username) { 
   echo '<form action="Login.php" method="POST">', "\n";
-  echo 'Username: <input type="text" name="username"><br>', "\n";
+  if ($username) {
+    echo "Username: <input type=\"text\" name=\"username\" value=\"$username\"><br>\n";
+  } else {
+    echo "Username: <input type=\"text\" name=\"username\"><br>\n";
+  }
   echo 'Password: <input type="text" name="password"><br>', "\n";
   echo '<input type="submit" name="login" value="login">', "\n";
@@ -19,12 +23,15 @@
 function projectform ($ID) {
     menu ('ipp.menu.dat', 'Select Project', 'ipp.css', $ID['link'], $ID['proj']);
+    if ($_GET['new'] && $_GET['proj']) {
+      echo "<p> Project is now <b>" . $_GET['proj'] . "</b></p>\n";
+    }
     echo "<p> Please select the project of interest </p>\n";
-    echo "<form action=\"SelectProject.php\" method=\"POST\">\n";
-    echo "Project: <input type=\"text\" name=\"proj\"><br>\n";
-    echo "<input type=\"submit\" name=\"project\">\n";
+    // echo "<form action=\"SelectProject.php\" method=\"POST\">\n";
+    // echo "Project: <input type=\"text\" name=\"proj\"><br>\n";
+    // echo "<input type=\"submit\" name=\"project\">\n";
 
     $pass = $ID['pass'];
-    echo "<input type=\"hidden\" name=\"pass\" value=\"$pass\">\n";
-    echo "</form>\n";
+    // echo "<input type=\"hidden\" name=\"pass\" value=\"$pass\">\n";
+    // echo "</form>\n";
 
     $db = dbconnect('ippadmin');
@@ -42,5 +49,9 @@
     echo "<tr class=select><th class=select> projects </th></tr>\n";
     while ($qry->fetchInto($row)) {
-      echo "<tr class=select><td class=select> $row[0] </td></tr>\n";
+      // add a link here to set the database
+      $tmp_proj = $row[0];
+      $tmp_link = "pass=$pass";
+      echo "<tr class=select><td class=select><a href=\"SelectProject.php?$tmp_link&proj=$tmp_proj&new=1\"> $row[0] </a></td></tr>\n";
+      // echo "<tr class=select><td class=select> $row[0] </td></tr>\n";
     }
     echo "</table>\n";
@@ -77,4 +88,11 @@
   $password = $_POST[password];
 
+  // if password is not specified, keep username and ask again
+  if ($password == "") {
+    menu ('ipp.menu.dat', 'Login', 'ipp.css', '', '');
+    loginform ($username);
+    menu_end ();
+  }
+
   $db = dbconnect('ippadmin');
 
@@ -84,7 +102,8 @@
   $qry = $db->query($sql);
   if (DB::iserror($db)) {
+    menu ('ipp.menu.dat', 'Login', 'ipp.css', '', '');
     echo "<b>error reading users table</b><br>\n";
     echo "Login Failed, please try again<br>\n";
-    loginform ();
+    loginform ("");
     menu_end();
   }
@@ -94,5 +113,5 @@
     menu ('ipp.menu.dat', 'Login', 'ipp.css', '', '');
     echo "Login Failed, please try again<br>\n";
-    loginform ();
+    loginform ("");
     menu_end ();
     exit ();
@@ -179,5 +198,5 @@
     menu('ipp.menu.dat', 'Login', 'ipp.css', '', '');
     logintext ();    
-    loginform ();
+    loginform ("");
     menu_end ();
   }
@@ -185,6 +204,7 @@
   $db = dbconnect ('ippadmin');
 
-  // make this a DB lookup
   $pass = $ID['pass'];
+
+  // search for password
   $sql = "SELECT username FROM cookies WHERE cookie = '$pass'";
   $qry = $db->query($sql);
@@ -192,14 +212,13 @@
     echo "<b>error reading users table</b><br>\n";
     echo "Login Failed, please try again<br>\n";
-    loginform ();
+    loginform ("");
     menu_end();
   }
   
-  # $success = (($username == "eugene") && ($password == "test"));
   $success = $qry->fetchInto($row);
   if (! $success) {
     menu('ipp.menu.dat', 'Login', 'ipp.css', '', '');
     echo "unknown user, please login again<br>\n";
-    loginform ();
+    loginform ("");
     menu_end ();
   }
