<?php
//not for distributor login
session_start();
ob_start();
include "header.php";
include "leftnav.php";
include "conn.php";


if (isset($_POST["submit"]))
{
	$username = $_POST["username"];
	$password = $_POST["password"];

	$query = "select userID from theusers where userName='$username' and passwd='$password'";
	$result = mysql_query($query);

	if (mysql_num_rows($result) > 0)
	{
		while ($row = mysql_fetch_row($result)) 
		{
			$userID = $row[0];
		}
		
		$query = "delete from loginusers where userID='$userID'";
		mysql_query($query) or die(mysql_error());
		
		$query = "insert into loginusers values('$userID', NOW(), '";
		$query .= session_id();
		$query .= "')";
		
		//echo $query;
		mysql_query($query) or die(mysql_error());
		
		$_SESSION["denglu"] = 1;
		header ("location: adm/index.php");
		exit;
	}
	else
	{
		$err = "invalid username and password combination";
	}
}

?>

<?php

?>
<td valign="top" class="border">
<br>
  <p class="heading"><a href="index.php"><font color="#66CC00">Home</font></a> 
    <font color="#66CC00">> Log in<br>
    <font color="#000000"><br>
    This section is for APP Administrator to manage dynamic website contents. 
    Log-in using the valid and Password.<br>
    <br>
    If you have difficulties in logging in, please e-mail the <a href="mailto:info@axon.com.sg?APP%20log-in%20problems">webmaster</a>.</font></font></p>
              <form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post">
    <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="97%" id="AutoNumber1" height="109" bgcolor="#C0C0C0" align="center">
      <tr> 
        <td width="100%" height="130" bgcolor="#FFFFFF"> <font color="#66CC00"><img src="img/adminbutton.jpg" width="237" height="21"></font><br> 
          <table width="96%" border="0" align="center">
            <tr> 
              <td colspan="2"><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="red"><?php echo ($err?$err:"&nbsp;"); ?></font></td>
            </tr>
            <tr> 
              <td width="38%"><font face="Verdana, Arial, Helvetica, sans-serif" size="2">User 
                ID:</font></td>
              <td width="62%"> <input name="username" size="20" maxlength="50" value="">
              </td>
            </tr>
            <tr> 
              <td width="38%"><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Password: 
                </font></td>
              <td width="62%"> <input type="password" name="password" size="20" maxlength="15" value="">
              </td>
            </tr>
            <tr> 
              <td align="right" width="38%">&nbsp; </td>
              <td width="62%"> <input type="submit" value="Login" name="submit"> 
              </td>
            </tr>
          </table></td>
      </tr>
    </table>
</form>
<p></p>
</td>
<?php
include "rightnews.php";
include "footer.php";
?>