做爰高潮a片〈毛片〉,尤物av天堂一区二区在线观看,一本久久A久久精品VR综合,添女人荫蒂全部过程av

最新文章專題視頻專題問答1問答10問答100問答1000問答2000關(guān)鍵字專題1關(guān)鍵字專題50關(guān)鍵字專題500關(guān)鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關(guān)鍵字專題關(guān)鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
當(dāng)前位置: 首頁 - 科技 - 知識(shí)百科 - 正文

PHP+MySql實(shí)現(xiàn)簡(jiǎn)單的留言板功能

來源:懂視網(wǎng) 責(zé)編:小采 時(shí)間:2020-11-02 18:26:12
文檔

PHP+MySql實(shí)現(xiàn)簡(jiǎn)單的留言板功能

PHP+MySql實(shí)現(xiàn)簡(jiǎn)單的留言板功能:【相關(guān)學(xué)習(xí)推薦:mysql教程】跟著書學(xué)的,代碼不是自己寫的,但是都能理解,有時(shí)間自己去寫個(gè)好看一點(diǎn)的吼吼吼~(不熟練花了一天的時(shí)間…留言板是接觸WEB開發(fā)的基礎(chǔ),寫一個(gè)留言板需要知道前端的一些基礎(chǔ)標(biāo)簽,對(duì)數(shù)據(jù)庫有一個(gè)了解會(huì)基礎(chǔ)SQL語言,PHP基礎(chǔ)
推薦度:
導(dǎo)讀PHP+MySql實(shí)現(xiàn)簡(jiǎn)單的留言板功能:【相關(guān)學(xué)習(xí)推薦:mysql教程】跟著書學(xué)的,代碼不是自己寫的,但是都能理解,有時(shí)間自己去寫個(gè)好看一點(diǎn)的吼吼吼~(不熟練花了一天的時(shí)間…留言板是接觸WEB開發(fā)的基礎(chǔ),寫一個(gè)留言板需要知道前端的一些基礎(chǔ)標(biāo)簽,對(duì)數(shù)據(jù)庫有一個(gè)了解會(huì)基礎(chǔ)SQL語言,PHP基礎(chǔ)

【相關(guān)學(xué)習(xí)推薦:mysql教程】

跟著書學(xué)的,代碼不是自己寫的,但是都能理解,有時(shí)間自己去寫個(gè)好看一點(diǎn)的吼吼吼~(不熟練花了一天的時(shí)間…

留言板是接觸WEB開發(fā)的基礎(chǔ),寫一個(gè)留言板需要知道前端的一些基礎(chǔ)標(biāo)簽,對(duì)數(shù)據(jù)庫有一個(gè)了解會(huì)基礎(chǔ)SQL語言,PHP基礎(chǔ)知識(shí),前段基礎(chǔ)+數(shù)據(jù)庫基礎(chǔ)+PHP基礎(chǔ)=>留言板。

前方高能哇(界面真的是吃藕誒…

先建一個(gè)數(shù)據(jù)庫,數(shù)據(jù)庫里有兩張表,一個(gè)存賬號(hào)密碼,一個(gè)存留言信息

//創(chuàng)建數(shù)據(jù)庫,里面有兩張表Admin和Message
create database gbook;
//創(chuàng)建Admin表,記錄用戶名和密碼
create table admin(
 username varchar(20) not null,
 userpass varchar(20) not null
);
//創(chuàng)建Message表,記錄留言的id,留言人,留言日期,留言內(nèi)容以及回復(fù)
create table message(
 id int(4) not null auto_increment primary key,
 author varchar(20) not null,
 addtime datetime not null,
 content varchar(1000) not null,
 reply varchar(1000) not null
);

首先實(shí)現(xiàn)用戶留言的部分,這是第一步,沒有留言index頁面就空了嘛~

<!-- 1.用戶填寫留言部分 send.php -->
<!-- 可以首先編寫send頁面,只有用戶提交了留言才能進(jìn)行后面的留言顯示,留言管理等等 -->
 
<?php
 $name = $_POST["name"];//從input里面?zhèn)鬟^來的name
 //看用戶是否提交了新留言,如果提交了,則寫入表message
 if( $name != ""){
 $content = $_POST["content"];
 //下面的代碼用于獲得當(dāng)前日期和時(shí)間
 $addtime = date("Y-m-d h:i:s");//得到日期
 $link = mysqli_connect("127.0.0.1","root","Vmorish");//PHP連接數(shù)據(jù)庫
 if( $link)
 echo "ok!<br>";
 else {
 echo "bad!<br>";
 }
 mysqli_select_db($link,"gbook");//選擇數(shù)據(jù)庫
 $insert = "insert into message(author,addtime,content,reply) values('$name','$addtime','$content','')";
 mysqli_query($link,$insert);
 mysqli_close($link);
 echo "<script language=javascript>alert('留言成功!單擊確定查看留言.');location.href='index.php';</script>";
 }
 mysqli_close($link);
 
 ?>
 
<html>
 
<head>
 <title>歡迎來到陳雨情的留言本吼吼吼</title>
</head>
 
<body>
 <!-- border-collapse:collapse合并表格的邊框 -->
 <table border=1 cellspacing=0 cellspadding=0 style="border-collapse:collapse" align=center width=400 bordercolor=black>
 <tr>
 <td height=100 bgcolor=#6c6c6c>
 <font style="font-size:30px" color=#ffffff face="黑體">歡迎來到×××的留言本吼吼吼</font>
 </td>
 </tr>
 <tr>
 <td height=25>
 <a href=send.php>[我要寫留言]</a> 
 <a href=login.php>[管理留言]</a>
 </td>
 </tr>
 <tr>
 <td height=200>
 <form method="POST" action="send.php">
 <table border="1" width="95%" id="table1" cellspacing="0" cellpadding="0" bordercolor="#808080" style="border-collapse:collapse" height="265">
 <tr>
 <td colspan="2" height="29">
 <p align="center">歡迎填寫你的留言</p>
 </td>
 </tr>
 <tr>
 <td width="32%">
 <p align="right">你的名字</p>
 </td>
 <td width="67%">
 <input type="text" name="name" size="20">
 </td>
 </tr>
 <tr>
 <td width="32%">
 <p>留言內(nèi)容</p>
 </td>
 <td width="67%">
 <textarea rows="10" name="content" cols="31"></textarea>
 </td>
 </tr>
 <tr>
 <td width="99%" colspan="2">
 <p align="center">
 <input type="submit" value="提交" name="B1">
 </p>
 </td>
 </tr>
 </table>
 </form>
 </td>
 </tr>
 <tr>
 <td height=80 bgcolor=#6c6c6c align=center>
 <font color="#FFFFFF">
 版權(quán)所有:<a href="http://blog.csdn.net/cherish0222" rel="external nofollow" rel="external nofollow" rel="external nofollow" >Vmorish</a><br>
 E-mail:vmorish@163.com
 </font>
 </td>
 </tr>
 </table>
 
</body>
 
</html>

效果:

接著就可以上主頁面了

<!-- 2.留言本首頁 index.php -->
<!-- 本頁面顯示十條最近的的留言,并且有分頁功能 -->
<html>
 
<head>
 <title>歡迎來到陳雨情的留言本吼吼吼</title>
 <style type="text/css">
 TD{
 font-size: 12px;
 line-height: 150%;
 }
 </style>
</head>
 
<body>
 <table border=1 cellspacing=0 cellspadding=0 style="border-collapse:collapse" align=center width=400 bordercolor=black height=382>
 <tr>
 <td height=100 bgcolor=#6c6c6c style="font-size:30px;line-height:30px">
 <font color=#ffffff face="黑體">歡迎來到×××的留言本吼吼吼</font>
 </td>
 </tr>
 <tr>
 <td height=25>
 <a href=send.php>[我要寫留言]</a> 
 <a href=login.php>[管理留言]</a>
 </td>
 </tr>
 <tr>
 <td height=200>
 <?php
 $link = mysqli_connect("127.0.0.1","root","Vmorish");
 mysqli_select_db($link,"gbook");
 $query = "select * from message";
 $result = mysqli_query($link,$query);
 if( mysqli_num_rows($result) < 1){
 echo " 目前數(shù)據(jù)表中還沒有任何留言!";
 }else{
 $totalnum = mysqli_num_rows($result);//獲取數(shù)據(jù)庫中所有數(shù)據(jù)條數(shù)
 $pagesize = 7;//每頁顯示7條
 $page = $_GET["page"];
 if( $page == ""){
 $page = 1;
 }
 $begin = ($page-1)*$pagesize;
 $totalpage = ceil($totalnum/$pagesize);
 //輸出分頁信息
 echo "<table border=0 width=95%><tr><td>";
 $datanum = mysqli_num_rows($result);
 echo "共有".$totalnum."條留言,每頁".$pagesize."條,共".$totalpage."頁。<br>";
 //輸出頁碼
 for( $i = 1; $i <= $totalpage; $i++){
 echo "<a href=index.php?page=".$i.">[".$i."] </a>";
 }
 echo "<br>";
 //從message表中查詢當(dāng)前頁面所要顯示的留言,并根據(jù)時(shí)間排序
 $query = "select * from message order by addtime desc limit $begin,$pagesize";
 $result = mysqli_query($link,$query);
 $datanum = mysqli_num_rows($result);
 //循環(huán)輸出所有留言,如果管理員已經(jīng)回復(fù)則同時(shí)輸出回復(fù)
 for( $i = 1; $i <= $datanum; $i++){//$datanum???
 $info = mysqli_fetch_array($result);
 echo "->[".$info['author']."]于".$info['addtime']."說:<br>";
 echo " ".$info['content']."<br>";
 if( $info['reply'] != ""){
 // <b></b>顯示粗體
 echo "<b>管理員回復(fù):</b>".$info['reply']."<br>";
 }
 echo "<hr>";
 }//else結(jié)束
 echo "</td></tr></table>";
 }
 mysqli_close($link)
 ?>
 </td>
 </tr>
 <tr>
 <td height=80 bgcolor=#6c6c6c align=center>
 <font color="#FFFFFF">
 版權(quán)所有:<a href="http://blog.csdn.net/cherish0222" rel="external nofollow" rel="external nofollow" rel="external nofollow" >Vmorish</a><br>
 E-mail:vmorish@163.com
 </font>
 </td>
 </tr>
 </table>
 
</body>
 
</html>

效果:

接著管理員登錄咯

<!-- 3.管理員登錄頁面 login.php -->
<!-- 供管理員登錄 -->
<!-- 體會(huì)session實(shí)現(xiàn)用戶登錄的方法 -->
 
<?php
 $name = $_POST["name"];
 if( $name != ""){
 $password = $_POST['password'];
 $link = mysqli_connect("127.0.0.1","root","Vmorish");
 mysqli_select_db($link,"gbook");
 $query = "select * from admin where username = '$name'";
 $result = mysqli_query($link,$query);
 if( mysqli_num_rows($result) < 1){
 echo "該用戶不存在,請(qǐng)重新登錄!<br>";
 }else{
 $info = mysqli_fetch_array($result);
 if( $info['userpass'] != $password){
 echo "密碼輸入錯(cuò)誤,請(qǐng)重新登錄!<br>";
 }else{
 //如果用戶名密碼都正確,則注冊(cè)一個(gè)session來標(biāo)記其登錄狀態(tài)
 echo "hhhh<br>";
 session_start();
 // $_SESSION["login"] = "YES";
 echo "<script language=javascript>alert('登錄成功!');location.href='manage.php';</script>";
 }
 }
 mysqli_close($link);
 }
 ?>
 
<html>
 
<head>
 <title>歡迎來到陳雨情的留言本吼吼吼</title>
</heda>
 
<body>
 
 <table border=1 cellspacing=0 cellspadding=0 style="border-collapse:collapse" align=center width=400 bordercolor=black height="358">
 <tr>
 <td height=100 bgcolor=#6c6c6c style="font-size:30px;line-height:30px">
 <font color=#ffffff face="黑體">歡迎來到×××的留言本吼吼吼</font>
 </td>
 </tr>
 <tr>
 <td height=25>
 <a href=send.php>[我要寫留言]</a> 
 <a href=login.php>[管理留言]</a>
 </td>
 </tr>
 <tr>
 <td height=178>
 <form method="POST" action="login.php">
 <table border="1" width="95%" id="table1" cellspcing="0" cellpadding="0" bordercolor="#808080" style="border-collapse" height="154">
 <tr>
 <td colspan="2" height="29">
 <p align="center">歡迎管理員登錄</p>
 </td>
 </tr>
 <tr>
 <td width="32%">
 <p align="center">用戶名</P>
 </td>
 <td width="67%">
 <input type="text" name="name" size="20">
 </td>
 </tr>
 <tr>
 <td width="32%">
 <p align="center">密 碼</p>
 </td>
 <td>
 <input type="password" name="password" size="20">
 </td>
 </tr>
 <tr>
 <td width="99%" colspan="2">
 <p align="center"><input type="submit" value="登錄" name="B1"></p>
 </td>
 </tr>
 </table>
 </form>
 </td>
 </tr>
 <tr>
 <td height=80 bgcolor=#6c6c6c align=center>
 <font color="#FFFFFF">
 版權(quán)所有:<a href="http://blog.csdn.net/cherish0222" rel="external nofollow" rel="external nofollow" rel="external nofollow" >Vmorish</a><br>
 E-mail:vmorish@163.com
 </font>
 </td>
 </tr>
 </table>
 
</body>
 
</html>

效果:

manage.php和reply.php和前面類似,就不給出了(我也還沒寫好誒…但要實(shí)現(xiàn)的跟前面類似

最后注銷登錄

<!-- 6.注銷登錄頁面 -->
<?php
 session_start();
 $_SESSION["login"]="";
 echo "已成功退出。[<a href=index.php>回首頁</a>]";
 exit;
 ?>

相關(guān)學(xué)習(xí)推薦:php編程(視頻)

聲明:本網(wǎng)頁內(nèi)容旨在傳播知識(shí),若有侵權(quán)等問題請(qǐng)及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

文檔

PHP+MySql實(shí)現(xiàn)簡(jiǎn)單的留言板功能

PHP+MySql實(shí)現(xiàn)簡(jiǎn)單的留言板功能:【相關(guān)學(xué)習(xí)推薦:mysql教程】跟著書學(xué)的,代碼不是自己寫的,但是都能理解,有時(shí)間自己去寫個(gè)好看一點(diǎn)的吼吼吼~(不熟練花了一天的時(shí)間…留言板是接觸WEB開發(fā)的基礎(chǔ),寫一個(gè)留言板需要知道前端的一些基礎(chǔ)標(biāo)簽,對(duì)數(shù)據(jù)庫有一個(gè)了解會(huì)基礎(chǔ)SQL語言,PHP基礎(chǔ)
推薦度:
標(biāo)簽: 功能 留言板 php
  • 熱門焦點(diǎn)

最新推薦

猜你喜歡

熱門推薦

專題
Top
主站蜘蛛池模板: 新乡县| 云梦县| 九龙坡区| 井冈山市| 西乌珠穆沁旗| 永春县| 怀柔区| 龙海市| 上栗县| 宁陕县| 津南区| 呼和浩特市| 屏南县| 阳春市| 凤冈县| 竹北市| 寿光市| 潜江市| 小金县| 景洪市| 汉阴县| 华宁县| 香港| 芷江| 香河县| 沧源| 博客| 阿瓦提县| 赞皇县| 读书| 蒙自县| 儋州市| 罗山县| 长泰县| 乌兰县| 金沙县| 徐闻县| 崇仁县| 静安区| 石景山区| 深圳市|