PHP開發簡易貼吧專案介紹

專案主要效果如下

貼吧主頁

<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"> 
<meta name="format-detection" content="telephone=no"> 
<title>php中文网贴吧</title>
<meta charset="utf-8">
    <style>
    body{
        background-color:#dceffe;
    }
    *{
        box-sizing:border-box;
    }
    .box{
        background-color:#fff;
        font-family:楷体;
        margin:0px auto;
        width:400px;
    }
    .box a:link,.box a:visited,.box a:hover{color:#000000;text-decoration:none; }
    .head{
        background-color:#0f8ff2;
        height:100px;
    }
    .tit{
        padding: 20px 20px;
        font-size:25px;
    }
    .content{
        width:400px;
        min-height:100px;
        border:1px solid #f0f0f0;
        padding:5px;
    }
    .list{
        width:400px;
    }         
    .hot{
        margin-left:20px;
        width:400px;
        border-bottom:1px solid #f0f0f0;
    }
    .con_tit{
        font-size:18px;
        margin:10px 0px 5px 0px;
        font-weight:bold;
    }     
    .con_des{
        text-indent:2em;
        font-size:16px;
        margin:5px 5px;
        
    }   
    ul{
        list-style:none;
        margin-left:-40px;

    }
    li{
        margin:15px -15px 0px 0px;
    }
    .index{
        margin:5px 0px 0px 50px ;
    }
    .info{
        font-size: 12px;
        border-bottom:1px solid #f0f0f0; 
        font-family:楷体;
        font-weight:bold;
    }
    .show_name{
        float:left;
        margin-left:10px;
    }
    .show_time{
        float:left;
        margin-left:20px;
    }
    .show_read{
        float:right;
        margin-right:20px;
    }
    .show_discuss{
        float:right;
        margin-right:10px;
    }
    .menu{
        padding:5px 10px;
    }
    .wel{
        margin-bottom: 10px
    }
    </style>
</head>
<body>
<div class="box">
    <div class="head">
        <div class="tit">php中文网贴吧</div>
    </div>
    <div class="menu">
            <div class="wel">欢迎您!admin</div>
        <span class="bg"><a href="home_publish.php">发布新帖</a></span>
        <span class="exit"><a href="home_exit.php">退出</a></span>
        </div>
    <div class="content">
        <div class="hot">
        <!-- 按浏览量排序,展示浏览量最高的两个 -->
            <div style="font-weight:bold;">热门帖子</div>
            <ul>
                            <li><a href="home_details.php?id=23">环境配置不好</a></li>
                                <li><a href="home_details.php?id=27">date()函数怎么使用啊</a></li>
                            </ul>
        </div>
        <!-- 帖子列表-->
                <div class="list">
        <!--内容部分-->
        <!--展示标题并设置链接-->
            <div class="con_tit"><a href="home_details.php?id=28">雾霾好大啊</a></div>
        <!--展示帖子内容-->  
            <div class="con_des">今天的雾霾真大</div>
            <div class="info">
                <div class="show_name">
                我是阿神                </div>
                <!--展示帖子发布时间--> 
                <div class="show_time">11-19 09:22</div>
                <!--展示帖子浏览量--> 
                <div class="show_read">浏览:4</div>
                <!--展示帖子回复量-->
                <div class="show_discuss">回复:
                2                </div>
                <div style="clear:both"></div>                
            </div>
        </div>
                <div class="list">
        <!--内容部分-->
        <!--展示标题并设置链接-->
            <div class="con_tit"><a href="home_details.php?id=27">date()函数怎么使用啊</a></div>
        <!--展示帖子内容-->  
            <div class="con_des">date()函数怎么使用啊,我总是写不对</div>
            <div class="info">
                <div class="show_name">
                晴子                </div>
                <!--展示帖子发布时间--> 
                <div class="show_time">11-18 11:52</div>
                <!--展示帖子浏览量--> 
                <div class="show_read">浏览:113</div>
                <!--展示帖子回复量-->
                <div class="show_discuss">回复:
                0                </div>
                <div style="clear:both"></div>                
            </div>
        </div>
                <div class="list">
        <!--内容部分-->
        <!--展示标题并设置链接-->
            <div class="con_tit"><a href="home_details.php?id=23">环境配置不好</a></div>
        <!--展示帖子内容-->  
            <div class="con_des">想问下大家都是怎么样配置环境的</div>
            <div class="info">
                <div class="show_name">
                我是阿神                </div>
                <!--展示帖子发布时间--> 
                <div class="show_time">11-18 11:37</div>
                <!--展示帖子浏览量--> 
                <div class="show_read">浏览:317</div>
                <!--展示帖子回复量-->
                <div class="show_discuss">回复:
                2                </div>
                <div style="clear:both"></div>                
            </div>
        </div>
                <div class="index">
            <a href="home_index.php?page=1">首页</a>
            <a href="home_index.php?page=0">上一页</a>
            <a href="home_index.php?page=2">下一页</a>
            <a href="home_index.php?page=4">末页</a>
            </div>
        </div>
        
    </div>



</body>
</html>

主要實作功能:帖子展示,熱門帖子展示,發布帖子

貼吧詳情頁

<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"> 
<meta name="format-detection" content="telephone=no"> 
<title>php中文网贴吧</title>
<meta charset="utf-8">
    <style>
    body{
        background-color:#dceffe;
    }
    *{
        box-sizing:border-box;
    }
    .box{
        background-color:#fff;
        font-family:楷体;
        margin:0px auto;
        width:400px;
    }
    .box a:link,.box a:visited,.box a:hover{color:#000000;text-decoration:none; }
    .head{
        background-color:#0f8ff2;
        height:100px;
    }
    .tit{
        padding: 20px 20px;
        font-size:25px;
    }
	img{
		width:200px;
	}
	.pic{
		text-align:center;
	}
	.centre{
		padding:10px;
		border-bottom: 1px solid #f0f0f0;
	}
	.floor,.name,.content,.pic{
		margin-bottom:0px;
	}
	.floor{
		font-size: 22px;
        margin-bottom:3px;
	}
	.name{
		font-size: 12px;
        margin-bottom:3px;
	}
	.reply{
		padding-top:10px;
        padding-left:10px; 
        margin-bottom:3px; 
	}
    .menu{
        padding:5px 10px;
        border-bottom:1px solid #f0f0f0; 
    }
    .wel{
        margin-bottom: 10px
    }
    </style>
</head>
<body>
<div class="box">
    <div class="head">
	    <div class="tit">php中文网贴吧</div>
    </div>
    <div class="menu">
                <div class="wel">欢迎您!admin</div>
            <span class="exit"><a href="home_index.php">首页</a></span>
            <span class="exit"><a href="home_exit.php">退出</a></span>
     
    </div>
        <div class="centre">
    	<div class="floor">1楼</div>
		<div class="name">
        晴子&nbsp;11-18 11:36        </div>
		<div class="content">各位大神给些意见啊</div>
    </div>
        <div class="centre">
    	<div class="floor">2楼</div>
		<div class="name">
        我是阿神&nbsp;11-18 11:39        </div>
		<div class="content">我也在学,大家一起加油啊</div>
    </div>
        <div class="centre">
    	<div class="floor">3楼</div>
		<div class="name">
        admin&nbsp;11-19 11:23        </div>
		<div class="content">认真去学会有收获的</div>
    </div>
        <!--回复部分-->
    <div class="reply">
        <form method="post" action="home_reply.php?fId=22">
            <div>回复内容:<br><textarea name="content" cols="40" rows="9"></textarea></div><br>
            <div><input type="submit" name="button" value="回复"></div><br>
        </form>
    </div>
</div>

</body></html>

#主要實現功能:帖子詳細內容展示,回复帖子

還有一些小功能,我們將在後面一一介紹

註:學習本課程之前,希望各位已經學習了我們網站的其它兩門課程

本課程用到了其中的登入、註冊、分頁等部分程式。

資料夾主要包含檔案如下:

#公用檔案

  • config.php:資料庫設定資訊

  • connect.php:資料庫連結

  • function.php:自訂公用函數

  • paging.php:分頁程式

#登入登錄檔

  • home_register.php :註冊頁面

  • home_regcheck.php:註冊處理頁面

  • home_login.php:登入頁面

  • #home_logincheck.php:登入處理頁面

  • home_exit.php:退出程式

專案首頁檔案

  • home_index.php:貼吧首頁
  • home_publish.php:發文頁面
  • home_publish_handle.php:發佈貼文處理程序

專案詳情頁檔案
  • home_details.php:貼文詳情頁
  • #home_reply.php:貼文回覆程式

###下面我們來開始從零建立我們的專案吧。 ###
繼續學習
||
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"> <meta name="format-detection" content="telephone=no"> <title>php中文网贴吧</title> <meta charset="utf-8"> <style> body{ background-color:#dceffe; } *{ box-sizing:border-box; } .box{ background-color:#fff; font-family:楷体; margin:0px auto; width:400px; } .box a:link,.box a:visited,.box a:hover{color:#000000;text-decoration:none; } .head{ background-color:#0f8ff2; height:100px; } .tit{ padding: 20px 20px; font-size:25px; } .content{ width:400px; min-height:100px; border:1px solid #f0f0f0; padding:5px; } .list{ width:400px; } .hot{ margin-left:20px; width:400px; border-bottom:1px solid #f0f0f0; } .con_tit{ font-size:18px; margin:10px 0px 5px 0px; font-weight:bold; } .con_des{ text-indent:2em; font-size:16px; margin:5px 5px; } ul{ list-style:none; margin-left:-40px; } li{ margin:15px -15px 0px 0px; } .index{ margin:5px 0px 0px 50px ; } .info{ font-size: 12px; border-bottom:1px solid #f0f0f0; font-family:楷体; font-weight:bold; } .show_name{ float:left; margin-left:10px; } .show_time{ float:left; margin-left:20px; } .show_read{ float:right; margin-right:20px; } .show_discuss{ float:right; margin-right:10px; } .menu{ padding:5px 10px; } .wel{ margin-bottom: 10px } </style> </head> <body> <div class="box"> <div class="head"> <div class="tit">php中文网贴吧</div> </div> <div class="menu"> <div class="wel">欢迎您!admin</div> <span class="bg"><a href="home_publish.php">发布新帖</a></span> <span class="exit"><a href="home_exit.php">退出</a></span> </div> <div class="content"> <div class="hot"> <!-- 按浏览量排序,展示浏览量最高的两个 --> <div style="font-weight:bold;">热门帖子</div> <ul> <li><a href="home_details.php?id=23">环境配置不好</a></li> <li><a href="home_details.php?id=27">date()函数怎么使用啊</a></li> </ul> </div> <!-- 帖子列表--> <div class="list"> <!--内容部分--> <!--展示标题并设置链接--> <div class="con_tit"><a href="home_details.php?id=28">雾霾好大啊</a></div> <!--展示帖子内容--> <div class="con_des">今天的雾霾真大</div> <div class="info"> <div class="show_name"> 我是阿神 </div> <!--展示帖子发布时间--> <div class="show_time">11-19 09:22</div> <!--展示帖子浏览量--> <div class="show_read">浏览:4</div> <!--展示帖子回复量--> <div class="show_discuss">回复: 2 </div> <div style="clear:both"></div> </div> </div> <div class="list"> <!--内容部分--> <!--展示标题并设置链接--> <div class="con_tit"><a href="home_details.php?id=27">date()函数怎么使用啊</a></div> <!--展示帖子内容--> <div class="con_des">date()函数怎么使用啊,我总是写不对</div> <div class="info"> <div class="show_name"> 晴子 </div> <!--展示帖子发布时间--> <div class="show_time">11-18 11:52</div> <!--展示帖子浏览量--> <div class="show_read">浏览:113</div> <!--展示帖子回复量--> <div class="show_discuss">回复: 0 </div> <div style="clear:both"></div> </div> </div> <div class="list"> <!--内容部分--> <!--展示标题并设置链接--> <div class="con_tit"><a href="home_details.php?id=23">环境配置不好</a></div> <!--展示帖子内容--> <div class="con_des">想问下大家都是怎么样配置环境的</div> <div class="info"> <div class="show_name"> 我是阿神 </div> <!--展示帖子发布时间--> <div class="show_time">11-18 11:37</div> <!--展示帖子浏览量--> <div class="show_read">浏览:317</div> <!--展示帖子回复量--> <div class="show_discuss">回复: 2 </div> <div style="clear:both"></div> </div> </div> <div class="index"> <a href="home_index.php?page=1">首页</a> <a href="home_index.php?page=0">上一页</a> <a href="home_index.php?page=2">下一页</a> <a href="home_index.php?page=4">末页</a> </div> </div> </div> </body> </html>