Location: PHPKode > projects > Radtracker > radtracker/login.php
<?php
session_register("lname");
session_register("pass");

if ($login) $lname = $login;
if ($pword) $pass = $pword;

include ("pagefunctions.php");
global $connection;
$db = mysql_select_db("radTracker", $connection) or die ("Couldn't connect to DB Radtracker");


$sql_command = "SELECT * FROM personnel WHERE Name = '$lname'";
$sql_result = mysql_query($sql_command,$connection) or die (mysql_error());

while ($row = mysql_fetch_array($sql_result)) {
  $tname = $row["Name"];
  $tpass = $row["Password"];

  if ($tname == $lname && $tpass == $pass) {
        
    if ($change == "made" && $npass1 == $npass2) {
      $pass = $npass1;
      $sql_command2 = "UPDATE personnel SET password='$pass' WHERE Name = '$lname'";
      $sql_result2 = mysql_query($sql_command2,$connection) or die (mysql_error());
      $extra = "You are a Valid User<br>Your password is now $pass";
      $change = "";
    }
    elseif ($change == "made" && $npass1 != $npass2) {
        $extra = "New Password and Confirm Password do not match!";
        $change = "true";
    }
    elseif ($change == "") {
      if ($from) {
          global $serverhome;
        header("Location: " . $serverhome . "$from");
      }
      
      $extra = "You are a Valid User<br><a href='$PHP_SELF?change=true'>Change your password</a>";
    }

    
    $mypass = "good";
  }

  else {
    $extra = "Incorrect Password for $tname";
    $mypass = "bad";
  }
}

gentop("Login");

echo "
<h1 align=\"center\">Login</h1>
<div align=\"center\">$extra
";

echo "
<form action=\"login.php\" method=\"post\">
<table align=\"center\">
<tr>
  <td>Login</td>
  <td>
  <select name=\"login\">";
  
  $sql_command = "SELECT Name FROM personnel ORDER BY Name";
  $sql_result = mysql_query($sql_command,$connection) or die (mysql_error());
  while ($row = mysql_fetch_array($sql_result)) {
    if ($row["Name"] == $lname) {
      $sel = "selected";
    }
    $tname2 = $row["Name"];
    echo "<option $sel value=\"$tname2\">$tname2</option>";
  }
echo "
  </select>
  </td>
</tr>";
if ($change == "true" && $mypass == "good") {
  $change = "made";
  echo "<tr><td>New Password</td><td><input type='password' name='npass1'><input type='hidden' name='change' value='$change'></td></tr>";
  echo "<tr><td>Confirm Password</td><td><input type='password' name='npass2'></td></tr>";
}
else {
  echo "
  <tr>
  <td>Password</td>
  <td><input type=\"password\" name=\"pword\"></td>
  </tr>";
}

echo "
  </table>
  <input type='hidden' name='from' value='$from'>
  <input type=\"submit\">
  </form>
  </div>
";

genbottom();
?>
Return current item: Radtracker