久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

使用PHP連接數據庫實現留言板功能的實例講解(推薦)

下面小編就為大家帶來一篇使用PHP連接數據庫實現留言板功能的實例講解(推薦)。小編覺得挺不錯的,現在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧

PHP實現留言板功能:

1 首先是登錄頁面:

<!DOCTYPE html>
<html>
 <head>
  <meta charset="UTF-8">
  <title>留言板登錄</title>
  <script src="bootstrap/js/jquery-1.11.2.min.js"></script>
  <script src="bootstrap/js/bootstrap.min.js"></script>
  <link href="bootstrap/css/bootstrap.min.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="stylesheet" type="text/css"/>
 </head>
 <style>
  .header{
   margin-left: 550px;
   margin-top: 150px;
   height: 300px;
   max-width: 300px;
  }
  .xiugai{
   max-width: 200px;
  }
  .login{
   margin-top: 10px;
  }
 </style>
 <body>
  <form action="messloginchuli.php" method="post">
  <div class="header">
   <h2>開發部內部留言板</h2>
   <div class="input-group xiugai">
    <span class="input-group-addon" >用戶名:</span>
    <input type="text" class="form-control" name="uid" placeholder="請輸入用戶名">
   </div>
   <div class="input-group xiugai" >
    <span class="input-group-addon">口令:</span>
    <input type="text" class="form-control" name="pwd" placeholder="請輸入口令">
   </div>
   <button type="submit" class="btn btn-success login">登錄</button>
  </div>
 </form>
 </body>
</html>

2 登錄頁面完成后要進入登錄處理頁面了,也就是上面提交到的messloginchuli.php

<?php
session_start();  // 登錄之后要把所包含登錄的頁面連接起來,開啟session
$uid = $_POST["uid"];
$pwd = $_POST["pwd"];
require_once "./DBDA.class.php";
$db = new DBDA();
$sql = "select password from yuangong where username='{$uid}'";
$arr = $db->query($sql,0);
//var_dump($arr[0][0]);
if($arr[0][0]=$pwd && !empty($pwd)){
 $_SESSION["uid"]=$uid;
 header("location:message.php");
}

?>

登錄頁面效果如圖:

使用PHP連接數據庫實現留言板功能的實例講解(推薦)

3.登錄完成后是進入主頁面,也就是顯示自己收到的對話內容,下面是設計的數據庫的表格和主頁面的代碼:

使用PHP連接數據庫實現留言板功能的實例講解(推薦)

<!DOCTYPE html>
<html>
 <head>
  <meta charset="UTF-8">
  <title></title>
  <script src="bootstrap/js/jquery-1.11.2.min.js"></script>
  <script src="bootstrap/js/bootstrap.min.js"></script>
  <link href="bootstrap/css/bootstrap.min.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="stylesheet" type="text/css"/>
 </head>
 <style>
  .mess{
   max-width: 800px;
   margin-left: 250px;
   margin-top: 150px;
  }
 </style>
 <body>
  <?php
  session_start();
  $uid = $_SESSION["uid"];
  if(empty($_SESSION["uid"])){
   header("location:messlogin.php");
   exit;
  }
  ?>
  <div >
   <a href="publish_info.php" rel="external nofollow" >發布信息</a>
   <a href="tuichuchuli.php" rel="external nofollow" >退出系統</a>
   </div>
  <table class="table table-bordered mess" >
   <caption >
    留言信息:
   </caption>
   
   <thead>
    <tr>
     <th>發送人</th>
     <th>發送時間</th>
     <th>接收人</th>
     <th>信息內容</th>
    </tr>
   </thead>
   <tbody>
    <?php
    require_once "./DBDA.class.php";
    $db = new DBDA();
    $sql = "select * from liuyan where recever='{$uid}' or recever='all'";
    $arr = $db->query($sql,0);
    foreach($arr as $v){
     echo "<tr>
     <td>{$v[1]}</td>
     <td>{$v[2]}</td>
     <td>{$v[3]}</td>
     <td>{$v[4]}</td>
    </tr>";
    }
    ?>
    
   </tbody>
  </table>

 </body>
</html>

退出登錄系統實現用戶注銷,返回登錄頁面功能代碼如下:

 <?php
session_start();
$uid = $_SESSION["uid"];
unset($uid);
header("location:messlogin.php");

?>

代碼寫到這里,比較重要的部分就完成了,下面是要進入發布信息頁面了,相當于之前寫的添加的頁面,其處理頁面也是和之前沒什么區別的,差別在于現在的處理頁面是在用戶登錄的情況下操作的,需要用session把所有的登錄情況下的頁面連接起來

主頁面效果如圖:

使用PHP連接數據庫實現留言板功能的實例講解(推薦)

使用PHP連接數據庫實現留言板功能的實例講解(推薦)

4.最后是信息發布頁面,可以給任何人發送信息

【網站聲明】本站除付費源碼經過測試外,其他素材未做測試,不保證完整性,網站上部分源碼僅限學習交流,請勿用于商業用途。如損害你的權益請聯系客服QQ:2655101040 給予處理,謝謝支持。

相關文檔推薦

這篇文章主要為大家詳細介紹了php實現留言板功能,會話控制的案例,具有一定的參考價值,感興趣的小伙伴們可以參考一下
主站蜘蛛池模板: 日韩在线精品视频 | 久久毛片| 久久免费精品 | 国产色网 | 精品影视| 操网站| 成人在线观看免费 | 国产精品成人国产乱一区 | 玖玖国产精品视频 | 欧美一区二区三区,视频 | 国产精品性做久久久久久 | 国产免费一区二区三区免费视频 | 亚洲一区二区三区四区五区午夜 | 欧美日韩精品一区二区天天拍 | 日韩一区精品 | 国产做a爱免费视频 | 中文字幕视频一区 | 在线观看黄免费 | 欧美精品免费观看二区 | 91精品观看 | 欧美日韩视频在线第一区 | 成人精品一区二区 | 天天色av | 精品一区国产 | 亚洲高清视频在线观看 | 国产一区二区三区精品久久久 | 日韩精品一区二区三区在线观看 | 欧美精品在欧美一区二区 | 久草在线免费资源 | 亚洲一区二区在线视频 | 激情欧美一区二区三区中文字幕 | 亚洲精品国产电影 | 黄色免费网址大全 | 99精品久久99久久久久 | 国产精品一区在线 | 久久免费大片 | 久草福利 | 91在线视频免费观看 | 日本一区二区高清不卡 | 天天干成人网 | 中文字字幕在线中文乱码范文 |