Location: PHPKode > projects > eCanteen > ecanteen/maintain/updatesupervisor.php
<html>
<header>
<LINK REL="stylesheet" TYPE="text/css" HREF="maintain.css">
</header>
<?

  global $conn;
  global $_POST;
  include("../include/constants.php");   
  mysql_free_result();
  $sql = @$_POST["sql"];
  $firstpw=@$_POST["passwordnew"];
  $secondpw=@$_POST["passwordchk"];
  $conn = mysql_connect(DB_SERVER, DB_USER, DB_PASS);
  mysql_select_db(DB_NAME);
  
  if ($sql=="update")
  {
    if ($firstpw==$secondpw)
    {
      if (strlen($firstpw)>0)
      {
      $password=md5(@$_POST["password"]);
      $sql = "update `supervisor` set `supervisorname`='" .@$_POST["supervisorname"] ."', `password`='" .$password ."', `siteadminname`= '" .@$_POST["siteadminname"] ."', `siteadminpw`= '" .@$_POST["siteadminpw"] ."' where (`supervisorid`=" .@$_POST["supervisorid"] .")";
      }else{
      $sql = "update `supervisor` set `supervisorname`='" .@$_POST["supervisorname"] ."', `siteadminname`= '" .@$_POST["siteadminname"] ."', `siteadminpw`= '" .@$_POST["siteadminpw"] ."' where (`supervisorid`=" .@$_POST["supervisorid"] .")";
      
      }
      mysql_query($sql, $conn) or die(mysql_error()); 
      $host  = $_SERVER['HTTP_HOST'];
      $uri   = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
      $extra = 'siteid.php?a=logout';
      header("Location: http://$host$uri/$extra");
      exit;

    }else{
      $errormsg="Passwords do not match.";  
    }
  }
  $sql = "select `supervisorid`, `supervisorname`, `password`, `siteadminname`, `siteadminpw` from `supervisor` where `supervisorid`=".@$_GET["id"];
 
  $res=mysql_query($sql, $conn) or die(mysql_error());
  $row = mysql_fetch_assoc($res) or $row = array(0 => "");

  echo $errormsg;

 
 

 
  
?>
<body>
<form action="updatesupervisor.php?id=<?echo @$_GET["id"] ?>" method="post">
<p><input type="hidden" name="sql" value="update"></p>
<table class="tbl" border="0" cellspacing="1" cellpadding="5"width="50%">
<tr>
<td class="hr"><? echo htmlspecialchars("ID")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="supervisorid" value="<? echo str_replace('"', '&quot;', trim($row["supervisorid"])) ?>"></td>
</tr>
<tr>
<td class="hr"><? echo htmlspecialchars("supervisorname")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="supervisorname" maxlength="40" value="<? echo str_replace('"', '&quot;', trim($row["supervisorname"])) ?>"></td>
</tr>
<tr>
<td class="hr"><? echo htmlspecialchars("New Password")."&nbsp;" ?></td>
<td class="dr"><input type="password" id="passwordnew" name="passwordnew" maxlength="40" value=""></td>
</tr>
<tr><tr><td></td><td></td></tr>
<td class="hr"><? echo htmlspecialchars("Password Check")."&nbsp;" ?></td>
<td class="dr"><input type="password" id="passwordchk" name="passwordchk" maxlength="40" value=""></td>
</tr>

<tr>
<td class="hr"><? echo htmlspecialchars("Site Admin Username")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="siteadminname" maxlength="40" value="<? echo str_replace('"', '&quot;', trim($row["siteadminname"])) ?>"></td>
</tr>

<tr>
<td class="hr"><? echo htmlspecialchars("Site Admin Password")."&nbsp;" ?></td>
<td class="dr"><input type="password" name="siteadminpw" maxlength="40" value="<? echo str_replace('"', '&quot;', trim($row["siteadminpw"])) ?>"></td>
</tr>

</table>
<p><input type="submit" name="action" value="Post"></p>
</form>
</body>
</html>

Return current item: eCanteen