<?php session_start();
include("../conn.php");
 ?><html>
<head>
<title>chat online</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="../temp.css" rel="stylesheet" type="text/css" />
<link href="../css.php?id=<?php echo $_SESSION["chatid"] ?>"  rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="home_main">
<h1>Chat Online - Login</h1>
<form method="post" action="index.php">
用户名:<input type="text" name="username" id="username" />&nbsp;&nbsp;
密码:<input type="password" name="password" id="password" />
<input type="submit" value="    登陆……  " />
<?php
if(!empty($_POST['username']) && !empty($_POST['password']))
{

$username=$_POST['username'];
$password=md5($_POST['password']);
$sql="select username,password,companyname from chat_user where username='$username' && password='$password'";
mysql_query("set names 'utf8'",$dbconn);
$result=mysql_query($sql,$dbconn);
$rows=mysql_num_rows($result);
if($rows>0)
{
	session_register("username");
	session_register("password");
	session_register("companyname");
	$_SESSION['username']=$username;
	$_SESSION['password']=$password;
	$_SESSION['companyname']=mysql_result($result,0,'companyname');
	
	$count=mysql_query("select * from chat_message where username='".$username."'");	 
	$counts=mysql_num_rows($count);
	$_SESSION["mycounts"]=$counts;

	echo "<script type='text/javascript'>window.location='login.php'</script>";
}
}
 ?>
</form>
</div>
<script type="text/javascript" src="../js/main.js"></script>
<script type="text/javascript">homepageload()</script>
</body>
</html>