Location: PHPKode > scripts > KubeStats > control/login.php
<?php
require_once("../includes/config.php");
require_once("../includes/functions/func.global.php");

// Connect to database
db_connect($config);

IF(isset($_POST['username']))
{
	IF(strlen($_POST['username']) == 0) 
	{
		$error[] = 'Error: Username Missing<br>';
	}
	IF(strlen($_POST['password']) == 0)
	{
		$error[] = 'Error: Password Missing<br>';
	}
	
	IF(!isset($error))
	{
		$query = "SELECT user_id,rem FROM ".$config['db']['pre']."users WHERE username='" . addslashes($_POST['username']) . "' AND password='" . addslashes(md5($_POST['password'])) . "' LIMIT 1";
		$query_result = mysql_query($query);
		while ($info = mysql_fetch_array($query_result))
		{
			$user_id = $info['user_id'];
			$remember = $info['rem'];
		}
		IF(isset($user_id))
		{
			session_start();
			$_SESSION['sadmin']['id'] = $user_id;
			$_SESSION['sadmin']['username'] = $_POST['username'];
			
			$rem = array();
			$rem['uid'] = $user_id;
			$rem['username'] = $_POST['username'];
			$rem['rem'] = $remember;
		
			setcookie('kstat',serialize($rem),time()+31536000);
			
			header("Location: index.php");
			exit;
		}
		ELSE
		{
			$error[] = "Error: Username & Password do not match";
		}
	}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>KubeStats</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
body {
	background-color: #FFFFFF;
}
.style1 {
	color: #FFFFFF;
	font-size: 12px;
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-weight: bold;
}
.style6 {font-size: 12px; font-weight: bold; font-family: Verdana, Arial, Helvetica, sans-serif; }
.style7 {
	color: #FF0000;
	font-size: 12px;
	font-family: Verdana, Arial, Helvetica, sans-serif;
}
.style8 {
	font-size: 12px;
	font-family: Arial, Helvetica, sans-serif;
	font-weight: bold;
}
-->
</style>
<script>
function clickchecked()
{
	if(document.f.remember.checked == true)
	{
		document.f.remember.checked=false;
	}
	else
	{
		document.f.remember.checked=true;
	}
}
</script>
<link rel="stylesheet" type="text/css" href="images/style.css">
</head>

<body onload="document.f.username.focus()">

<br>
<table width="600" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
  <td><span class="statstitle">KubeStats</span><br></td>
  </tr>
</table><br>
<table width="600" border="0" align="center" cellpadding="1" cellspacing="0">
  <tr>
    <td width="50%" height="200" align="center" valign="middle" bgcolor="#627eb7"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
	  <tr>
	  <form action="login.php" method="post" name="f" id="f">
        <td bgcolor="#DDE3F0"><div align="center">
          <table border="0" cellspacing="0" cellpadding="3">
            <tr>
              <td class="style8"><div align="left">Username</div></td>
            </tr>
            <tr>
              <td><input name="username" id="username" type="text" style="width: 150px;" value="<? IF(isset($_POST['username'])){ echo stripslashes($_POST['username']); } ?>"></td>
            </tr>
            <tr>
              <td class="style8"><div align="left">Password</div></td>
            </tr>
            <tr>
              <td><input style="width: 150px;" type="password" name="password"></td>
            </tr>
            <tr>
              <td align="left"><input name="remember" type="checkbox" id="remember" value="1">
                <span onclick="clickchecked();" style="cursor:pointer;">Remember Me</span></td>
            </tr>
            <tr>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td><input onClick="submit();document.f.Submit.disabled=true;" style="width: 150px;" type="submit" name="Submit" value="login"></td>
            </tr>
          </table>
        </div></td>
		  </form>
      </tr>
    </table></td>
  </tr>
</table>
</body>
</html>
Return current item: KubeStats