<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="../temp.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/temp.js"></script>
<style type="text/css">
body{ background:#0066CC}
</style>
<div style="width:100%; height:300px; margin:0 auto; margin-top:80px; background:#fff;" id="etwchatmessage">
<?php
include("../conn.php");
 ?>
<form name="form1" method="post" action="index.php" id="form1">
  <table style="background:#fff; width:800px; margin:0 auto;">
  
  	<tr>
  	  <td colspan="2"><div align="center"><strong>添 加 用 户</strong></div></td>
    </tr>
      	<tr>
    	<td><div align="right">公司名称:</div></td>
        <td><input type="text" name="companyname" id="companyname"  /><!--onchange="checkcompany()"--> 
        格式:拼音:公司电话,同一公司请用相同公司名称</td>
    </tr>
  	<tr>
  	  <td><div align="right">公司编号:</div></td>
  	  <td><input type="text" name="userid" id="userid" readonly /><span>同一公司请用同一ID号,ID号为该客户的ChatId</span></td>
	  </tr>
  	<tr>
    	<td><div align="right">用户名:</div></td>
        <td><input type="text" name="username" id="username" onchange="checkuser()"  /> 
          <span id="showstate"> 用客户邮箱地址 </span></td>
    </tr>
  	<tr>
    	<td><div align="right">密码:</div></td>
        <td><input type="password" name="password" id="password" value="123456" /> <span>默认密码为123456</span></td>
    </tr>
  	<tr>
    	<td><div align="right">确认密码:</div></td>
        <td><input type="password" name="repassword" id="repassword" value="123456" /></td>
    </tr>

  	<tr>
    	<td><div align="right">注册时间:</div></td>
        <td><input type="text" name="regtime" value="<?php echo date("Y-m-d h:i:s")  ?>" readonly /></td>
    </tr>
  	<tr>
    <td>    </td>
   
  	   <td><input type="button" value="添 加 用 户" onclick="dochangeinfo()"></td>
    </tr>
  </table>
 </form>
</div>
<script type="text/javascript">
var getinput=document.getElementsByTagName("input")
for(i=0;i<getinput.length;i++)
{
	getinput[i].onmouseover=function()
	{
		this.focus();
	}
}
function dochangeinfo()
{
if(document.getElementById("password").value==document.getElementById("repassword").value && document.getElementById("companyname").value!="" && document.getElementById("password").value!="" && document.getElementById("userstatenow").value=="ok")
	{
		document.getElementById("form1").submit()
	}
}
</script>
<?php
if(!empty($_POST['password']))
{
	$sql="insert into chat_user(userid,username,password,companyname,regtime) values(".$_POST['userid'].",'".$_POST['username']."','".md5($_POST['password'])."','".$_POST['companyname']."','".$_POST['regtime']."')";
	mysql_query("set names'utf8'",$dbconn);
	mysql_query($sql,$dbconn);
	echo "<script type='text/javascript'>alert('添加成功');</script>";
	echo "<meta http-equiv='refresh' content='0' />";
}
mysql_close($dbconn);
 ?>