<?php
//-----------------------------------------------------------------------------
//    ID002同学录 单班级 (PHP & MySQL) 1.0 标准版
//-----------------------------------------------------------------------------
//    Copyright(C) aNErG, 2003. All rights reserved
//
//    技术支持 http://anerg.126.com
//-----------------------------------------------------------------------------
//    本软件对个人完全免费使用
//
//    如用于商业用途,您必须与我联系并支付RMB ￥20
//-----------------------------------------------------------------------------
 if (empty($HTTP_COOKIE_VARS["class_username"])){echo "请先<a herf=index.php>登录</a>！";exit;}?>
<? if($mod==update){
require('function.php');
include ('conn.php');

if($HTTP_POST_VARS["userpwd"]=="" || $HTTP_POST_VARS["useremail"]=="" || !ereg("^[a-zA-Z0-9_\.]+\@([0-9A-Za-z][0-9A-Za-z-]+\.)+[A-Za-z]{2,3}$",$HTTP_POST_VARS["useremail"]))
{echo "<div align='center'>您的输入有误，请确定密码和E-mail的输入都是正确的.</div>";
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>成员资料更新</title>
<link href="css.css" rel="stylesheet" type="text/css">
<meta http-equiv=Refresh content="2; url=javascript:history.back(1)">
</head>

<body>
<? exit;}
$username=$HTTP_COOKIE_VARS["class_username"];
$userpwd=$HTTP_POST_VARS["userpwd"];
if($userpwd==$HTTP_COOKIE_VARS["class_userpwd"]){$userpwd=$userpwd;
}else{$userpwd=htmlspecialchars($HTTP_POST_VARS["userpwd"]);
$userpwd = encrypt($userpwd);}
$useremail=htmlspecialchars($HTTP_POST_VARS["useremail"]);
$sex=$HTTP_POST_VARS["sex"];
if($HTTP_POST_VARS["userqq"]==""){$userqq="--";}
else{$userqq=htmlspecialchars($HTTP_POST_VARS["userqq"]);}
if($HTTP_POST_VARS["usermsn"]==""){$usermsn="--";}
else{$usermsn=htmlspecialchars($HTTP_POST_VARS["usermsn"]);}
if($HTTP_POST_VARS["usericq"]==""){$usericq="--";}
else{$usericq=htmlspecialchars($HTTP_POST_VARS["usericq"]);}
if($HTTP_POST_VARS["userphone"]==""){$userphone="--";}
else{$userphone=htmlspecialchars($HTTP_POST_VARS["userphone"]);}
if($HTTP_POST_VARS["mobilephone"]==""){$mobilephone="--";}
else{$mobilephone=htmlspecialchars($HTTP_POST_VARS["mobilephone"]);}
if($HTTP_POST_VARS["birthday"]==""){$birthday="我的生日才不要告诉你呢";}
else{$birthday=htmlspecialchars($HTTP_POST_VARS["birthday"]);}
$userinfo=$HTTP_POST_VARS["userinfo"];
$userinfo=checkinfo($userinfo);
$query="update classuser set userpwd='$userpwd',useremail='$useremail',sex='$sex',userqq='$userqq',usermsn='$usermsn',usericq='$usericq',birthday='$birthday',userphone='$userphone',mobilephone='$mobilephone',userinfo='$userinfo' 
 where username='$username'";
$result=mysql_db_query("$dbname",$query);
  setcookie("class_username",$username,time()+650);
  setcookie("class_userpwd",$userpwd,time()+650);
echo"更新成功！自动返回首页。";
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>成员资料更新</title>
<link href="css.css" rel="stylesheet" type="text/css">
<meta http-equiv=Refresh content="2; url=javascript:window.close()">
</head>
<? exit;}
include ('conn.php') ;
$username=$HTTP_COOKIE_VARS["class_username"];
$userpwd=$HTTP_COOKIE_VARS["class_userpwd"];
$query="select userpwd,useremail,sex,userqq,usermsn,usericq,birthday,userphone,mobilephone,userinfo from classuser where username='$username'";
$result=mysql_db_query("$dbname",$query);
$arr=mysql_fetch_array($result);
         $checkuserpwd=$arr["userpwd"];
		 $useremail=$arr["useremail"];
		 $sex=$arr["sex"];
		 $userqq=$arr["userqq"];
		 $usermsn=$arr["usermsn"];
		 $usericq=$arr["usericq"];
		 $birthday=$arr["birthday"];
		 $userphone=$arr["userphone"];
		 $mobilephone=$arr["mobilephone"];
		 $userinfo=$arr["userinfo"];
		 $add_date=$arr["add_date"];
	if($userpwd!=$checkuserpwd){echo "你不是这个用户！";exit;}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>更新资料</title>
<link href="css.css" rel="stylesheet" type="text/css">
</head>

<body>
<form name="form1" method="post" action="<?php echo "$PHP_SELF?mod=update"; ?>">
                
  <table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr> 
      <td colspan="2"> <div align="center"><?php echo $username ?>请填写你要更新的内容</div></td>
    </tr>
    <tr> 
      <td width="37%"> <div align="right">*新密码:</div></td>
      <td width="63%"><input name="userpwd" type="password" value="<?php echo $checkuserpwd ?>"></td>
    </tr>
    <tr> 
      <td width="37%"> <div align="right">*E-mail:</div></td>
      <td><input type="text" name="useremail" value="<?php echo $useremail ?>"></td>
    </tr>
    <tr> 
      <td width="37%"> <div align="right">性别:</div></td>
      <td> BOY 
        <input name="sex" type="radio" value="Boy" checked> &nbsp;GIRL 
        <input name="sex" type="radio" value="Girl"> </td>
    </tr>
    <tr> 
      <td width="37%"> <div align="right">QQ:</div></td>
      <td><input type="text" name="userqq" value="<?php echo $userqq ?>"></td>
    </tr>
    <tr> 
      <td width="37%"> <div align="right">MSN:</div></td>
      <td><input type="text" name="usermsn" value="<?php echo $usermsn ?>"></td>
    </tr>
    <tr> 
      <td width="37%"> <div align="right">ICQ:</div></td>
      <td><input type="text" name="usericq" value="<?php echo $usericq ?>"></td>
    </tr>
    <tr> 
      <td width="37%"> <div align="right">电话:</div></td>
      <td><input type="text" name="userphone" value="<?php echo $userphone ?>"></td>
    </tr>
    <tr> 
      <td width="37%"> <div align="right">移动通讯:</div></td>
      <td><input type="text" name="mobilephone" value="<?php echo $mobilephone ?>"></td>
    </tr>
    <tr> 
      <td width="37%"> <div align="right">生日:</div></td>
      <td><input type="text" name="birthday" value="<?php echo $birthday ?>">
        (1982-01-13) </td>
    </tr>
    <tr> 
      <td width="37%"> <div align="right">个人介绍:</div></td>
      <td><textarea name="userinfo" cols="35" rows="6"><?php echo $userinfo ?></textarea> 
        <br>
        (不要超过100字)</td>
    </tr>
    <tr> 
      <td width="37%"> <div align="right"></div></td>
      <td>&nbsp;</td>
    </tr>
    <tr> 
      <td width="37%"> <div align="right"></div></td>
      <td><input type="submit" name="Submit" value="提交"> <input type="reset" name="Submit2" value="重置"></td>
    </tr>
    <tr> 
      <td colspan="2">&nbsp; </td>
    </tr>
  </table>
              </form>
<?php require("bottom.php"); ?>