<?php session_start() ?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<div class="etwchathistory etwchathistory_email" id="etwchatmessage">
<?php
include("../conn.php");
if($_SESSION['username']=='')
{
$_SESSION['username']="-----";
}
$sql="select username,companyname,userid,regtime from chat_user where username='".$_SESSION['username']."'";
mysql_query("set names'utf8'",$dbconn);
$result=mysql_query($sql,$dbconn);
 ?>
<form name="form1" method="post" action="#" id="form1">
  <table>
  	<tr>
  	  <td colspan="2"><div align="center"><strong>资 料 修 改</strong></div></td>
    </tr>
  	<tr>
    	<td><div align="right">用户名:</div></td>
        <input type="hidden" name="userid" value="<?php echo mysql_result($result,0,'userid') ?>" />
        <td><input type="text" name="username" id="username" value="<?php echo mysql_result($result,0,'username') ?>" readonly="readonly" /></td>
    </tr>
  	<tr>
    	<td><div align="right">密码:</div></td>
        <td><input type="password" name="password" id="password" /></td>
    </tr>
  	<tr>
    	<td><div align="right">确认密码:</div></td>
        <td><input type="password" name="repassword" id="repassword" /></td>
    </tr>
  	<tr>
    	<td><div align="right">公司名称:</div></td>
        <td><input type="text" name="companyname" id="companyname" value="<?php echo mysql_result($result,0,'companyname') ?>" /></td>
    </tr>
  	<tr>
    	<td><div align="right">注册时间:</div></td>
        <td><input type="text" name="regtime" value="<?php echo mysql_result($result,0,'regtime') ?>" readonly /></td>
    </tr>
  	<tr>
    <td>
    </td>
  	   <td><input type="button" value="修 改 资 料" onclick="dochangeinfo()"></td>
    </tr>
  </table>
 </form>
</div>
<?php
mysql_free_result($result);
 ?>
<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("form1").submit()
	}
}
</script>
<?php
if(!empty($_POST['password']))
{
	$sql="update chat_user set password='".md5($_POST['password'])."',companyname='".$_POST['companyname']."' where userid=".$_POST['userid'];
	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);
 ?>