<?php session_start();
	include("../koneksi.php"); 
	include("init.php");
	$err = $_REQUEST["err"];		
	$aksi = $_REQUEST["aksi"];	
	if($aksi=="Log in") {
		$username=$_POST["username"];
		$pass=$_POST["pass"];
		$strSQL="select * from user where username='".$username."'";
		// echo $strSQL;
		$err=1;
		if ($hasil = mysql_query($strSQL)) {
			while ($data = mysql_fetch_array($hasil)) {
				if($data["username"] != $username || $data["password"] != $pass ) {
					$err=2;
				} else {
					$err=0;
					$_SESSION["username"] = $data["username"];
					$_SESSION["iduser"]   = $data["admin_id"];
					$_SESSION["thisPage"] = $thisPage;
					$_SESSION["thisUrl"]  = $thisUrl;
				}
			}
		}
		
		$param = '';
		if ($err==1) {
			$param = 'error1/';
		} else if ($err==2) {
			
		}
		
		echo "<script language=JavaScript>";
		echo "	location.href = '".$thisPage."';";
		echo "</script>";
	} 
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<title> WEBSITE BACKOFFICE </title>
		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
		<link href="style.css" rel="stylesheet" type="text/css">
		<script language="JavaScript" type="text/javascript" src="richtext.js"></script>
		<script language="JavaScript" type="text/javascript">
		<!--
		function submitForm() {
			//make sure hidden and iframe value are in sync before submitting form
			//to sync only 1 rte, use updateRTE(rte)
			//to sync all rtes, use updateRTEs
			updateRTE('deskripsi');
			//updateRTEs();
			//alert("rte1 = " + document.RTEDemo.content.value);
			
			//change the following line to true to submit form
			return true;
		}
		
		//Usage: initRTE(imagesPath, includesPath, cssFile)
		initRTE("images/", "", "");
		//-->
		</script>				
	</head>	
	<body>
		<center>
			<table width="1000" height="500" border="0">
				<tr valign="top">
					<td width="207" class="bg">
						<?php include("kiri.php"); ?>
					</td>
					<td width="10"></td>
					<td width="783">
						<!-- Begin Kanan -->
						<?php include ("logo.php"); ?>
						<!-- Begin Kanan -->
						<form method="post" action="login.php" enctype="multipart/form-data" name="form1">
							<table width="33%" cellpadding="3" cellspacing="1" border="0" bgcolor="#cccccc">
								<tr height="25" bgcolor="#006666">
									<td align="left" colspan="2">
										<font color="#FFFFFF">&nbsp;<strong>Login Form</strong></font>
									</td>
								</tr>
								<tr bgcolor="#FFFFFF" height="30">
									<td width="18%" align="left">Username</td>
									<td align="left"><input type="text" name="username" size="25"></td>
								</tr>
								<tr bgcolor="#FFFFFF" height="30">
									<td align="left">Password</td>
									<td align="left"><input type="password" name="pass" size="25"></td>
								</tr>
								<?php 
								if($err){
									?>
									<tr bgcolor="#FFFFFF">
										<td colspan="2" align="right">
											<font color="#990000"><strong>Username dan/atau Password Anda Salah !.</strong></font>
										</td>
									</tr>								
									<?php
								}
								?>
								<tr bgcolor="#FFFFFF">
									<td colspan="2" align="right">
										<input type="submit" name="aksi" id="aksi" value="Log in">
									</td>
								</tr>
							</table>
						</form>
						
						<!-- end Kanan -->
					</td>
				</tr>
			</table>
		</center>
	</body>
</html>	