<?php session_start();?>
  <?php include 'header.php'; ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<div align="center">
 
 
          <table width="866" border="0">
            <tr> 
              <td width="414" height="40"><div align="right"> <font face="Century Gothic, Comic Sans MS, Courier, Curlz MT, Franklin Gothic Demi, Franklin Gothic Demi Cond, Goudy Stout, Lucida Sans Typewriter, Lucida Sans Unicode">
                <script language="JavaScript">

mydate = new Date();myday = mydate.getDay();mymonth = mydate.getMonth();myweekday= mydate.getDate();weekday= myweekday;myyear= mydate.getFullYear();year = myyear

if(myday == 0)	        day = " Sunday, "      

else if(myday == 1)     day = " Monday, "

else if(myday == 2)     day = " Tuesday, "   

else if(myday == 3)     day = " Wednesday, "   

else if(myday == 4)     day = " Thursday, "

else if(myday == 5)     day = " Friday, "

else if(myday == 6)     day = " Saturday, "

if(mymonth == 0)        month = "January "

else if(mymonth ==1)    month = "February "

else if(mymonth ==2)    month = "March "

else if(mymonth ==3)	month = "April "

else if(mymonth ==4)  	month = "May "

else if(mymonth ==5) 	month = "June "

else if(mymonth ==6) 	month = "July "

else if(mymonth ==7) 	month = "August "

else if(mymonth ==8) 	month = "September "

else if(mymonth ==9) 	month = "October "

else if(mymonth ==10) 	month = "November "

else if(mymonth ==11) 	month = "December"

document.write("<b><align=left><valign=top><strong><font face=verdana font color=red size=2></strong>"+day );

document.write(myweekday+" "+month+ ", " + myyear + "</font></b>");

//-->

</script>
                  </font></div></td>
            </tr>
          </table>
          <h2><font face="Century Gothic, Comic Sans MS, Courier, Curlz MT, Franklin Gothic Demi, Franklin Gothic Demi Cond, Goudy Stout, Lucida Sans Typewriter, Lucida Sans Unicode">
		<?php 
		$message = '<font color=red>Please insert username and password</font>';
		if (isset($_POST['login'])) {
			$username = trim(addslashes($_POST['username']));
			$password = trim(addslashes($_POST['password']));
			
			if ($username != '' && $password != '' && $password != '') {
				include 'open_connection.php';
				$sql = "SELECT user_name, user_password, user_section  FROM user
						WHERE user_name = '$username' AND user_password = '$password'";
												
				$result = mysql_query($sql) or die('Query failed. ' . mysql_error());
				$row = mysql_fetch_array($result, MYSQL_ASSOC);
				
				if (mysql_num_rows($result) == 1) {
					$_SESSION['isLogged_in'] = true;
					$_SESSION['username'] = $row['username'];
					$_SESSION['section'] = $row['section'];
					//$_GET['kodpengguna'] = $row['kodpengguna'];
					//$kodpengguna = $_GET['kodpengguna'];
					
					if( $_SESSION['section'] == 'admin')
						{	
							//echo "<script language='javascript'>window.location='home_admin.php?kodpengguna=$kodpengguna'/script>";
							echo "<script language='javascript'>window.location='home_admin.php'</script>";
							}
					else if($_SESSION['section'] == 'ict')
						{
						echo "<script language='javascript'>window.location='user_ict.php'</script>";
						
						}
					else if($_SESSION['section'] == 'finance')
						{
						echo "<script language='javascript'>window.location='user_finance.php'</script>";
					
				}
				else if($_SESSION['section'] == 'fnb')
						{
						echo "<script language='javascript'>window.location='user_fnb.php'</script>";
					
				} 
				else if($_SESSION['section'] == 'sales')
						{
						echo "<script language='javascript'>window.location='user_sales.php'</script>";
					
				} 
				else if($_SESSION['section'] == 'facility')
						{
						echo "<script language='javascript'>window.location='user_facility.php'</script>";
					
				} 
				else if($_SESSION['section'] == 'humancapital')
						{
						echo "<script language='javascript'>window.location='user_directory.php'</script>";}
					
				}
				
				else
					$message = '<script type="text/javascript">
						window.alert("Username and password invalid")
						</script>';
				} else {
				$message = '<script type="text/javascript">
						window.alert("Please insert username and password again")
						</script>';
			}
		}
		?>
	
            <img src="images/login.jpg" width="130" height="72"></font></h2>
          <form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
            <p><font face="Arial, Helvetica, sans-serif">Username : </font><font face="Century Gothic, Comic Sans MS, Courier, Curlz MT, Franklin Gothic Demi, Franklin Gothic Demi Cond, Goudy Stout, Lucida Sans Typewriter, Lucida Sans Unicode"> 
              <input name="username" type="text">
              <br>
			  <br>
              <font face="Arial, Helvetica, sans-serif">Password</font><font face="Arial, Helvetica, sans-serif">&nbsp;:</font> 
              <input name="password" type="password">
              </font>
            <br>
            </p>
           
              <table width="135" style="margin-left:50px" border="0">
                <tr>
                 <!--<td width="17"><input type="hidden" name="kodpengguna" value="<?php // echo $kodpengguna; ?>"></td>-->  
				  <td width="63" align="right"><input name="login" type="submit" value="Login"></td>
                  <td width="64"><input type="reset" name="Reset" value="Reset"></td>
                </tr>
              </table>
  </form>
          <table width="160" border="0" style="margin-left:80px">
            <tr>
              <td  width="154"><img src="images/register.jpg" width="154" height="41"></td>
             
            </tr>
          </table>
     <?php echo $message ?> 
        </td>
    </tr>
   
  </table>
  	</br>
    </br>
	</br>
    </br>
</div>
</body>
</html>
 <?php include 'footer.php'; ?>
