個人管理:
班級通訊錄:class/address.php
<?
session_start(); // 開始session
if(!session_is_registered("userregister")||($userregister==""))//檢查是否注冊,如userregister未注冊或session為空值,重新注冊.
{
echo "<a href='../index.php'>請重新注冊<BR>";
exit;
}
?>
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<TITLE>班級通訊錄</TITLE>
<style type="text/css">
<!--
.white12 { font-size: 12pt; color: #FFFFFF; text-decoration: none}
.blue9 { font-size: 9pt; color: #9999FF}
-->
</style>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<table width="98%" border="0" cellspacing="0" cellpadding="0" height="65">
<tr>
<td width="35%"><img src="image/classlogo.gif" width="224" height="60"> </td>
<td width="65%">
<table width="97%" border="1" cellspacing="0" cellpadding="0" bordercolorlight="#CC0000" bordercolordark="#FFFFFF" bordercolor="#FFFFFF">
<tr>
<td><img src="image/aslist.gif" width="470" height="70" alt="班級通訊錄"></td>
</tr>
</table>
</td>
</tr>
</table>
<?php
include "config.php";
$result = mysql_query("SELECT * FROM user",$db);
$row=mysql_num_rows($result);//查看結果有多少行
for ($i=0;$i<=($row-1);$i++) {
$name=mysql_result($result,$i,'name');
$sex=mysql_result($result,$i,'sex');
$birth=mysql_result($result,$i,'birth');
$ph=mysql_result($result,$i,'ph');
$bp=mysql_result($result,$i,'bp');
$email=mysql_result($result,$i,'email');
$oicq=mysql_result($result,$i,'oicq');
$work=mysql_result($result,$i,'work');
$photo=mysql_result($result,$i,'photo');
$ad=mysql_result($result,$i,'ad');
$post=mysql_result($result,$i,'post');
$account=mysql_result($result,$i,'account');
$face=mysql_result($result,$i,'face');
$face='image/face/icon'.$face;
echo "<table width='76%' border='1' cellspacing='0' cellpadding='0' bordercolorlight='#330099' bordercolordark='#FFFFFF' align='center' class='blue9'> <tr bgcolor='#3399FF'> <td colspan='8'> <div class='white12' align='center'>......................○班級通訊錄○....................</div> </td> </tr> <tr> <td width='30%'><img src='$face.gif' width='32' height='32'> 姓名:$name</td> <td colspan='6'>性別:$sex</td> <td width='35%'>生日:$birth</td> </tr> <tr> <td colspan='7'>電話: $ph</td> <td width='34%'>傳呼:$bp</td> </tr> <tr> <td colspan='7'>Email:<a href='mailto:$email'>$email</a></td> <td width='34%'>oicq:$oicq</td> </tr> <tr> <td colspan='7'>工作單位:$work</td> <td width='34%'>郵編:$post</td></tr> <tr><td colspan='8'>通訊地址:$ad</td></tr> <tr> <td colspan='8'>個人照片:$photo</td> </tr> <tr> <td colspan='8'>個人說明:$account</td> </tr></table>";
}
?>
</BODY>
</HTML>
個人資料修改:class/modify.php
<?
session_start(); // 開始session
if(!session_is_registered("userregister")||($userregister==""))//檢查是否注冊,如userregister未注冊或session為空值,重新注冊.
{
echo "<a href='../index.php'>請重新注冊<BR>";
exit;
}
?>
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<TITLE>個人資料修改</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<?php
include "config.php";
if ($submit){
if (!$username||!$psw||!$psw2||!$name||!$ad||!$ph||!$email){ //檢查是否填寫完整
echo "對不起,您必須填所有帶*的項目!<BR>"."<a href='javascript:history.back()'>重填</a>";
exit;
}
$user=trim($username);
$psw=trim($psw);
$psw2=trim($psw2);
$name=trim($name);
$birth=trim($birth);
$work=trim($work);
$ad=trim($ad);
$post=trim($post);
$ph=trim($ph);
$bp=trim($bp);
$email=trim($email);
$oicq=trim($oicq);
$account=strip_tags(trim($account));//去掉首尾空格及html標記
$signature=strip_tags(trim($signature));
//檢查密碼重復是否正確
if (!$psw==$psw2){
echo "請確認密碼,<a href='javascript:history.back()'>返回</a>";
exit;
}
//檢查email的合法性
if(!ereg('^[-!#$%&'*+./0-9=?A-Z^_`a-z{|}~]+'.'@'.'[-!#$%&'*+\/0-9=?A-Z^_`a-z{|}~]+.'.'[-!#$%&'*+\./0-9=?A-Z^_`a-z{|}~]+$',$email)&&$email){
echo "email不合法!<BR>"."<a href='register_step2.php?yname=$name'>重填</a><BR>";
exit;}
//寫入數據庫
$sql="UPDATE user SET user='$user',psw='$psw',name='$name',sex='$sex',birth='$birth',work='$work',ad='$ad',post='$post',ph='$ph',bp='$bp',email='$email',oicq='$oicq',account='$account',signature='$signature',face='$face' where user='$userregister'";
$result = mysql_query($sql,$db);
mysql_close($db);
//發祝賀郵件
$subject="祝賀你成功修改個人信息".$sitename."!";//主題
$message=$name.",你好:<BR> 祝賀你成功修改個人信息!您的用戶名為".$username.",密碼為".$psw."<BR>現在登陸<a href='$url'>$sitename</a>";//信件內容
$headers .= "Content-Type: text/html; charset=gb2312n"; // Mime type
mail($email,$subject,$message,$headers);
echo "恭喜您修改成功!一封歡迎信已發到您的郵箱,請注意查收。";
exit;
}
$result = mysql_query("SELECT * FROM user where user='$userregister'",$db);
$psw=mysql_result($result,0,"psw");
$name=mysql_result($result,0,"name");//讀取個人注冊信息
$sex=mysql_result($result,0,"sex");
$birth=mysql_result($result,0,"birth");
$work=mysql_result($result,0,"work");
$ad=mysql_result($result,0,"ad");
$post=mysql_result($result,0,"post");
$ph=mysql_result($result,0,"ph");
$bp=mysql_result($result,0,"bp");
$email=mysql_result($result,0,"email");
$oicq=mysql_result($result,0,"oicq");
$photo=mysql_result($result,0,"photo");
$account=mysql_result($result,0,"account");
$signature=mysql_result($result,0,"signature");
$face=mysql_result($result,0,"face");
mysql_close($db);
?>
<table width='95%' border='0' cellspacing='0' cellpadding='0' align='center'>
<tr>
<td colspan="2">
<div align="center"><img src="image/classlogo.gif" width="224" height="60"></div>
</td>
</tr>
<tr>
<td>
<div align="center">個人資料修改<br>
注意不要有空格,帶*的項目為必填。</div>
</td>
</tr>
<tr>
<td colspan="2">
<form method='post' action='<? echo $PHP_SELF;?>'>
<table width="95%" border="1" cellspacing="1" cellpadding="0" align="center" bordercolor="#FFCC00">
<tr>
<td height="153" width="60%"><br>
用戶名:
<input type='Text' name='username' size='12' maxlength='12' value="<? echo $userregister;?>">
*<br>
(英文字母或加數字,長度不超過12)<br>
密碼:
<input type='password' name='psw' size='8' maxlength='8' value="<? echo $psw; ?>">
*<br>
(英文字母或加數字,長度不超過8個字符)<br>
確認密碼:
<input type='password' name='psw2' size='8' maxlength='8' value="<? echo $psw; ?>">
*<br>
姓名:
<input type='Text' name='name' size='8' maxlength='8' value="<? echo $name; ?>">
*<br>
性別:男
<input type='radio' name='sex' value='男' <? if ($sex=='男'){echo "checked";} ?>>
女
<input type='radio' name='sex' value='女' <? if ($sex=='女'){echo "checked";} ?>>
<br>
生日:<input type="text" name="birth" size="12" maxlength="12" value="<? echo $birth; ?>"><br>
工作單位:
<input type='Text' name='work' size='30' maxlength='50' value="<? echo $work; ?>">
<br>
通訊地址:
<input type='Text' name='ad' size='30' maxlength='50' value="<? echo $ad; ?>">
*<br>
郵編:
<input type='Text' name='post' size='6' maxlength='6' value="<? echo $post; ?>">
<br>
電話:
<input type='Text' name='ph' size='15' maxlength='30' value="<? echo $ph; ?>">
*<br>
傳呼:
<input type='Text' name='bp' size='15' maxlength='20' value="<? echo $bp; ?>">
<br>
Email:
<input type='Text' name='email' size='15' maxlength='35' value="<? echo $email; ?>">
*<br>
oicq:
<input type='Text' name='oicq' size='12' maxlength='12' value="<? echo $oicq; ?>">
<br>
個人說明:(在通訊錄裡顯示,不超過125個漢字)<BR>
<textarea name='account' cols='50' rows='5'><? echo $account; ?></textarea>
<br>
個人簽名:(在留言簿的自動簽名,不超過125個漢字)<br>
<textarea name="signature" cols="50" rows="5"><? echo $signature; ?></textarea>
</td>
<td height="153" width="40%"><br>
選擇一個自己喜歡的頭像:<br>
<?
for ($i=1;$i<=64;$i++){
echo "<img src='image/face/icon".$i.".gif' width='32' height='32'>";
echo "<input type='radio' name='face' value='$i' ";
if ($face==$i){
echo "checked";
}
echo ">";
if (($i%4)==0){ //隔4行,換行
echo "<br>";
}
}
?><br>
</td>
</tr>
</table>
<div align="center">
<br>
<input type='Submit' name='submit' value='提交'>
<input type='reset' name='Reset' value='重寫 '>
</div>
</form>
</td>
</tr>
</table>
</BODY>
</HTML>
上傳照片:class/uploadphoto.php
<?
session_start(); // 開始session
if(!session_is_registered("userregister")||($userregister==""))//檢查是否注冊,如userregister未注冊或session為空值,重新注冊.
{
echo "<a href='../../index.php'>請重新注冊<BR>";
exit;
}
?>
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<TITLE>上傳照片</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<?php
include "../config.php";
if ($upload){
if ($picurl=="none"){
echo "你沒有上傳任何文件.";
exit;
}
$v=opendir("image");
if ($v==0)
{ mkdir("image"); //若目錄不存在,則新建一個
$v=opendir("image"); //取得目錄handle
}
$up=copy("$picurl","image/$picurl_name");
if($up==1)
{
//初始化寫入內容
$result = mysql_query("SELECT * FROM user where user='$userregister'",$db);//查詢以往照片信息
$photo=mysql_result($result,0,'photo');
$photo=str_replace("'","'",$photo);//將'用'代替
$photo=$photo."<a href='upload/image/$picurl_name'>看照片</a>|";//加上此次內容
mysql_query("UPDATE user SET photo='$photo' where user='$userregister'",$db);//寫入
mysql_close($db);
echo "文件上傳成功!<BR>";
echo "文件名:$picurl_name 文件大小:$picurl_size byte 文件類型:$picurl_type<BR>";
}
else
{echo "文件上傳失敗.";exit;}
unlink ($picurl); //從臨時文件夾中刪除檔案$picurl
closedir ($v); //關閉目錄handle
exit;
}
?>
<table width="95%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="56" width="32%"><img src="../image/classlogo.gif" width="224" height="60"></td>
<td height="56" width="68%">
<div align="center">上傳照片</div>
</td>
</tr>
<tr>
<td height="108" colspan="2"><form action="<? echo $PHP_SELF;?>" method="post" enctype="multipart/form-data" name="UL">
<!--注意:這裡必須加上‘enctype="multipart/form-data" ',否則不會產生上
傳動作-->
<div align="center">上傳照片:
<input type="file" name="picurl" size="15" accept="image/x-png,image/gif,image/jpeg">
<br>
<input type="Submit" name="upload" value="上傳">
<input type="reset" name="Reset" value="重寫">
</div>
</form>
</td>
</tr>
</table>
</BODY>
</HTML>