程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> PHP編程 >> 關於PHP編程 >> 杏林同學錄(五)

杏林同學錄(五)

編輯:關於PHP編程

密碼查詢:class/querypsw.php
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<TITLE>詢問密碼</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<?php
  include "config.php";
//詢問班級注冊問題密碼
  if ($class){
   $headers .= "Content-Type: text/html; charset=gb2312n"; // Mime type
   $subject="詢問班級注冊問題密碼 ";                        //主題
   $message=nl2br($message);
   $message="查詢人:".$name."<BR>留言:<BR>".$message;     //內容
   mail($superemail,$subject,$message,$headers);
   echo "恭喜您,您的請求已經向管理員發出,近期內請注意查收email。";
   exit;
  }
  //詢問個人注冊密碼
  if ($member){  
  $result = mysql_query("SELECT * FROM user where user='$username'",$db);
  if (mysql_num_rows($result)==0){  //若返回列的數目為0,說明無此資料
echo "我們的數據庫中無此用戶,請確認。注意大小寫。<a href='javascript:history.back()'>返回</a>";
exit;}
   $myemail=mysql_result($result,0,"email");//讀取user數據庫中的email
    if (!$myemail){                         //如果還沒有email,則返回
     echo "我們的數據庫中沒有您的email,請再次填寫。<a href='javascript:history.back()'>返回</a>";
     exit;
    }
$psw=mysql_result($result,0,"psw");      //密碼
$name=mysql_result($result,0,"name");    //姓名
$subject="詢問個人注冊密碼";
$message=$name.",您好。您的用戶名是".$username.",密碼是".$psw."。<BR>-----------------------<BR><a href='".$url."'>".$sitename."</a>";      //信件內容
$headers .= "Content-Type: text/html; charset=gb2312n"; // Mime type
mail($myemail,$subject,$message,$headers);
   echo "恭喜您,系統已經向您的信箱中發出了答復信件,請注意查收email。";
   exit;
  }
?>  
<table width="93%" border="0" cellspacing="0" cellpadding="0" align="center" height="286">
  <tr>  
        <td height="75" colspan="2">  
          <div align="center">詢問密碼<br>
          </div>
        </td>
      </tr>
      <tr>  
        <td height="75" width="47%">
          <form name="form1" method="post" action="<? echo $PHP_SELF;?>"><div align="center">詢問班級注冊問題答案<br>
            您的姓名  
            <input type="text" name="name">
            <br>您的留言(寫上能證實您身份的簡短留言及email地址)
<textarea name="message" rows="3" cols="50"></textarea>
            <br>
            系統將向班級管理員發送您的請求,是否確認?<br>

          <input type="submit" name="class" value="確認">
            <input type="reset" name="cancel" value="重填">
            <br>
          </div></form>
        </td>
        <td height="75" width="53%">
          <div align="center">
        <form name="form2" method="post" action="<? echo $PHP_SELF;?>">
          詢問個人注冊密碼<br>
          <br>
          您的用戶名(不是姓名)<br>
          <br>

          <input type="text" name="username">
          <br>
          <br>
          <br>
            系統將會向您注冊的信箱中發發送密碼,是否確認?<br>
          <input type="submit" name="member" value="確認">
          <input type="reset" name="cancel2" value="重填">
        </form>
        </div>
        </td>
      </tr>
    </table>    

</BODY>
</HTML>
悄悄話:privatenote.php
<?
session_start(); // 開始session
if(!session_is_registered("userregister")||($userregister==""))//檢查是否注冊,如userregister未注冊或session為空值,重新注冊.
{
echo "<a href='../index.php'>請重新注冊<BR>";
exit;
}
//刪除留言
include "config.php";
if ($del=="1"){
mysql_query("delete from privatenote where id='$id'",$db); //以id為刪除標志
echo "刪除成功!";
}
//添加留言
if ($Submit){
$id=time();                     //以時間戳為記錄號
$time=date("Y年m月d日 h:i:s A");//留言時間
$result = mysql_query("SELECT * FROM user where user='$userregister'",$db);
$fromuser=mysql_result($result,0,'name');                       //發消息人姓名
$result = mysql_query("SELECT * FROM user where name='$yname'",$db);
$touser=mysql_result($result,0,'user'); ;          //接受人用戶名
$message=nl2br(strip_tags($ynote));//留言內容
mysql_query("INSERT INTO privatenote (id,fromuser,touser,time,message) values ('$id','$fromuser','$touser','$time','$message')",$db); //寫入數據庫
echo "留言成功!";
}
?>
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<TITLE>悄悄話</TITLE>
<style type="text/css">
<!--
.blue9 {  font-size: 10pt; color: #9999FF; text-decoration: none}
.black10 {  font-size: 10pt}
-->
</style>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<table width="64%" border="1" cellspacing="1" cellpadding="1" align="center" ">
  <tr>  
    <td colspan="2" height="63">  
      <div align="center"><img src="image/classlogo.gif" width="224" height="60">  
      </div>
    </td>
  </tr>
  <tr>
    <td class="blue9" colspan="2">  
      <div align="center">
      <?
      $result = mysql_query("SELECT * FROM user where user='$userregister'",$db);
      $name=mysql_result($result,0,"name");//姓名
      echo $name;
      ?>
      的悄悄話</div>
    </td>
  </tr>
  <tr>  
    <td class="blue9" colspan="2">  
      <?php
$result = mysql_query("SELECT * FROM privatenote where touser='$userregister' ORDER BY time DESC",$db);
$row=mysql_num_rows($result);        //悄悄話總數
            $unlook=0;   
              if (!$row==0){
              for ($i=0;$i<$row;$i++){
               $id=mysql_result($result,$i,'id');//留言id
               $fromuser=mysql_result($result,$i,'fromuser');//留言人姓名
               $time=mysql_result($result,$i,'time');        //留言時間
               $message=mysql_result($result,$i,'message');  //留言內容
               $look_s="已看過";                             //注釋
               $look=mysql_result($result,$i,'look');        //是否看過
               if ($look=="0"){$unlook++;$look_s="尚未看過";} //計算未看過的悄悄話數目,並改變注釋
               mysql_query("UPDATE privatenote SET look='1' where id='$id'",$db);       //將悄悄話看過狀態改為1
               echo "第",$i+1,"條 發出人:",$fromuser," 留言時間:",$time,"<BR>";
               echo " 留言內容:",$message,"<BR>------",$look_s;
               echo "<a href='$PHP_SELF?del=1&id=$id'>刪除</a><HR>";
              }
              }
              echo "悄悄話總數:",$row,".",$unlook,"條新悄悄話.";
         ?>
</td>
  </tr>
  <tr>  
    <td class="black10" colspan="2">  
      <form method="post" action="<?php echo $PHP_SELF;?>">
        <p align="center">您要給誰發悄悄話?  

          <select name="yname">
            <?
            $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');  //姓名
             echo "<option>",$name,"</option>";
            }
            mysql_close($db);
            ?>
          </select>
          <br>
          留言內容:<br>
          <textarea name="ynote" cols="60" rows="6"></textarea>
          <br>
          <b>  
          <input type="submit" name="Submit" value="確認">
          </b>  
          <input type="reset" name="cancel" value="重寫">
        </p>
      </form>
    </td>
  </tr>
</table>
</BODY>
</HTML>

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved