亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

php實(shí)現(xiàn)留言板功能(會(huì)話控制)

 更新時(shí)間:2017年05月23日 09:26:36   作者:ChrissZhao  
這篇文章主要為大家詳細(xì)介紹了php實(shí)現(xiàn)留言板功能,會(huì)話控制的案例,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了php留言板功能的具體代碼,供大家參考,具體內(nèi)容如下

數(shù)據(jù)庫(kù)用到的三張表

一.登錄界面 (denglu.php   login.php)

1.denglu.php

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>

<body>
<h1>開(kāi)發(fā)部?jī)?nèi)部留言板</h1>
<form action="login.php" method="post">
<div>用戶名:<input type="text" name="UserName" /></div>
<div>口令:<input type="password" name="PassWord" /></div>
<input type="submit" value="登錄" />
<a href="denglu.php" style="text-decoration:none"><input type="button" value="復(fù)位" /></a>
</form>
</body>
</html>

2.login.php

<?php
session_start();
$UserName = $_POST["UserName"];
$PassWord = $_POST["PassWord"];

require "DBDA.class1.php";
$db = new DBDA();
$sql = "select PassWord from yuangong where UserName = '{$UserName}'";
$arr = $db->query($sql);

if(count($arr))
{
  if($arr[0][0] == $PassWord && !empty($PassWord))
  {
    //存儲(chǔ)用戶名
    $_SESSION["UserName"] = $UserName;
    
    header("location:main.php");
  }
}
else
{
  header("location:denglu.php");
}

二.主界面(main.php   tuichu.php)

1.main.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>無(wú)標(biāo)題文檔</title>
</head>

<body>
<?php
session_start();
  
//  防止繞過(guò)登陸直接進(jìn)入主界面
if(empty($_SESSION["UserName"]))
{
  header("location:denglu.php");
  exit;
}
  
require "DBDA.class1.php";
$db = new DBDA();
$UserName = $_SESSION["UserName"];
?>
<div>
<a href="fabu.php">發(fā)布信息</a>
<a href="tuichu.php">退出系統(tǒng)</a>
</div><br /><br />
<h1>留言信息:</h1>
<table width="100%" border="1" >
  <tr>
    <td>發(fā)送人</td>
    <td>發(fā)送時(shí)間</td>
    <td>接收人</td>
    <td>信息內(nèi)容</td>
  </tr>
   <?php
  
  //顯示接收者是我的,或者是所有人的
  $sql = "select * from liuyan where Recever='{$UserName}' or Recever='suoyou'";
  $arr = $db->query($sql);
  foreach($arr as $v)
  {
  
     echo "<tr>
          <td>{$v[1]}</td>
        <td>{$v[3]}</td>
        <td>{$v[2]}</td>
        <td>{$v[4]}</td>
        </tr>";
  }
  
  ?>  

</table>
</body>
</html>

2.tuichu.php

<?php
session_start();
unset($_SESSION["UserName"]);
header("location:denglu.php"); 

三.發(fā)送頁(yè)面(fabu.php   fabuchuli.php)

1.fabu.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>無(wú)標(biāo)題文檔</title>
</head>

<body>
<div>
<a href="main.php">查看信息</a>
<a href="tuichu.php">退出系統(tǒng)</a>
</div>
<h1>信息發(fā)送:</h1>
<form action="fabuchuli.php" method="post">
<div>接收人:
<select name="jsr">
  <option value="suoyou">所有人</option>
  <?php
  session_start();
  $UserName = $_SESSION["UserName"];
  require"DBDA.class1.php";
  $db = new DBDA();
  //方法一
  $sql = "select friend.Friend,yuangong.Name from friend,yuangong where friend.Friend = yuangong.UserName and friend.Me = '{$UserName}'";
  $arr = $db->query($sql);
    
  foreach($arr as $v)
  {
    echo "<option value='{$v[0]}'>{$v[1]}</option>";
  }
  //方法二
  /*$sql = "select Friend from friend where Me ='{$UserName}'";
  $arr = $db->query($sql);
  foreach($arr as $v)
    {
      $v[0];
      $sname = "select Name from yuangong where UserName = '{$v[0]}'";
      $aname = $db->query($sname);
      echo"<option value='{$v[0]}'>{$aname[0][0]}</option>";
    }*/
  ?>        
</select></div>
<div>信息內(nèi)容:<textarea name="neirong"></textarea></div>
<input type="submit" value="發(fā)送" />
<a href="fabu.php" style="text-decoration:none"><input type="button" value="復(fù)位" /></a>
</form>
</body>
</html>

2.fabuchuli.php

<?php
session_start();
$UserName = $_SESSION["UserName"];
$jsr = $_POST["jsr"];
$nr = $_POST["neirong"];
$Times = date("Y-m-d H:i:s");


require"DBDA.class.php";
$db = new DBDA();
$sql = "insert into liuyan values('','{$UserName}','{$jsr}','{$Times}','{$nr}')";
$db->query($sql,0);
header("location:fabu.php");

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • 檢測(cè)codeigniter腳本消耗內(nèi)存情況的方法

    檢測(cè)codeigniter腳本消耗內(nèi)存情況的方法

    這篇文章主要介紹了檢測(cè)codeigniter腳本消耗內(nèi)存情況的方法,實(shí)例分析了codeigniter中memory_usage方法及{ memory_usage}偽變量的使用技巧,需要的朋友可以參考下
    2015-03-03
  • PHP中文件讀、寫、刪的操作(PHP中對(duì)文件和目錄操作)

    PHP中文件讀、寫、刪的操作(PHP中對(duì)文件和目錄操作)

    現(xiàn)在我把php中的這些函數(shù)做一詳細(xì)總結(jié)并實(shí)例示范如何使用.,關(guān)于對(duì)應(yīng)的函數(shù)詳細(xì)介紹,請(qǐng)查閱php手冊(cè).此處只總結(jié)重點(diǎn).和需要注意的地方.(這在php手冊(cè)是沒(méi)有的.)
    2012-03-03
  • PHP array_reduce()函數(shù)的應(yīng)用解析

    PHP array_reduce()函數(shù)的應(yīng)用解析

    這篇文章主要介紹了PHP array_reduce()的應(yīng)用,本文通過(guò)代碼舉例給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2018-10-10
  • ThinkPHP部署Workerman的成功使用示例

    ThinkPHP部署Workerman的成功使用示例

    本文介紹thinkphp中關(guān)于composer集成workerman的方法,并解決了安裝過(guò)程 中遇到的錯(cuò)誤,實(shí)現(xiàn)了和woerkman進(jìn)行握手和通信的demo。用戶可以在此基礎(chǔ)上按自己的邏輯實(shí)現(xiàn)一個(gè)聊天系統(tǒng)或者客服系統(tǒng)。
    2023-06-06
  • thinkphp中AJAX返回ajaxReturn()方法分析

    thinkphp中AJAX返回ajaxReturn()方法分析

    這篇文章主要介紹了thinkphp中AJAX返回ajaxReturn()方法,結(jié)合實(shí)例形式分析了thinkPHP中ajax操作的功能、數(shù)據(jù)返回格式以及ajaxReturn方法的簡(jiǎn)單使用技巧,需要的朋友可以參考下
    2016-12-12
  • Swoole擴(kuò)展的6種模式深入詳解

    Swoole擴(kuò)展的6種模式深入詳解

    這篇文章主要介紹了Swoole擴(kuò)展的6種模式深入詳解,6種模式講解的很詳細(xì),有感興趣的同學(xué)可以跟著小編一起來(lái)研究下
    2021-03-03
  • php單例模式的簡(jiǎn)單實(shí)現(xiàn)方法

    php單例模式的簡(jiǎn)單實(shí)現(xiàn)方法

    下面小編就為大家?guī)?lái)一篇php單例模式的簡(jiǎn)單實(shí)現(xiàn)方法。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2016-06-06
  • PHP時(shí)間戳格式全部匯總 (獲取時(shí)間、時(shí)間戳)

    PHP時(shí)間戳格式全部匯總 (獲取時(shí)間、時(shí)間戳)

    下面小編就為大家?guī)?lái)一篇PHP時(shí)間戳格式全部匯總 (獲取時(shí)間、時(shí)間戳)。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2016-06-06
  • php使用curl模擬登錄后采集頁(yè)面的例子

    php使用curl模擬登錄后采集頁(yè)面的例子

    php使用curl模擬登錄后采集頁(yè)面的例子,附帶php curl模塊的開(kāi)啟辦法。
    2013-11-11
  • PhpStorm2020 + phpstudyV8 +XDebug的教程詳解

    PhpStorm2020 + phpstudyV8 +XDebug的教程詳解

    這篇文章主要介紹了PhpStorm2020 + phpstudyV8 +XDebug的教程詳解,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-09-09

最新評(píng)論