简单的用php+txt做的论坛代码_PHP

WBOY
发布: 2016-06-01 12:38:21
原创
1380 人浏览过

在没有数据库的支持的情况下用txt和php可以做论坛吗当然可以了。是不是很复杂阿也不是非常的简单。下面就给出这个例子供大家参考



首先是制作一个输入界面




!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

HTML>HEAD>TITLE>PHP4 Input Script/TITLE>

META http-equiv=content-type content=text/html;charset=iso-8859-1>

META content="Microsoft FrontPage 4.0" name=GENERATOR>/HEAD>

BODY>

TABLE height=495 cellSpacing=0 cellPadding=0 width=578 border=0 cool gridx="16"

showgridx usegridx gridy="16" showgridy usegridy>

TBODY>

TR height=64>

TD width=20 height=29>SPACER type="block" width="1" height="64">/TD>

TD width=20 height=29>/TD>

TD width=24 height=29>/TD>

TD width=14 height=29>/TD>

TD width=14 height=29>/TD>

TD width=28 height=29>/TD>

TD vAlign=top align=left width=203 colSpan=4 height=29 xpos="128" content

csheight="32">

H3 align="center">Forum: title goes here/H3>/TD>

TD vAlign=top align=left width=103 height=29 xpos="128" content

csheight="32">

/TD>

TD width=128 height=29>/TD>

/TR>

TR height=48>

TD width=20 height=29>SPACER type="block" width="1" height="48">/TD>

TD width=20 height=7>/TD>

TD width=24 height=7>/TD>

TD width=14 height=7>/TD>

TD vAlign=top align=left width=46 colSpan=4 height=7 xpos="96" content

csheight="32">Name:/TD>

TD vAlign=top align=left width=199 colSpan=2 height=7 xpos="144">INPUT

size=24 name=name>/TD>

TD vAlign=top align=left width=101 height=7 xpos="144">/TD>

TD width=128 height=7>/TD>

/TR>

tr>

TD width=20 height=31>/TD>

TD width=20 height=31>/TD>

TD width=24 height=31>/TD>

TD vAlign=top align=left width=14 height=31 xpos="96" content

csheight="32">/TD>

TD vAlign=top align=left width=44 colSpan=3 height=31 xpos="96" content

csheight="32">Email:/TD>

TD vAlign=top align=left width=201 colSpan=3 height=31 xpos="144">INPUT

size=24 name=email>/TD>

TD width=101 height=31>/TD>

TD width=136 height=31>/TD>

/tr>

TR height=32>

TD width=20 height=26>SPACER type="block" width="1" height="32">/TD>

TD width=20 height=26>/TD>

TD width=24 height=26>/TD>

TD width=14 height=26>/TD>

TD vAlign=top align=left width=45 colSpan=4 height=26 xpos="96" content

csheight="32">Topic:/TD>

TD vAlign=top align=left width=199 colSpan=2 height=26 xpos="144">INPUT

size=24 name=topic>/TD>

TD vAlign=top align=left width=101 height=26 xpos="144">/TD>

TD width=128 height=26>/TD>

/TR>

TR height=29>

TD width=20 height=19>SPACER type="block" width="1" height="29">/TD>

TD width=20 height=19>/TD>

TD width=24 height=19>/TD>

TD vAlign=top align=left width=62 colSpan=6 height=19 xpos="80" content

csheight="29">Message:/TD>

TD width=199 height=19>/TD>

TD width=101 height=19>/TD>

TD width=128 height=19>/TD>

/TR>

TR height=243>

TD width=20 height=243>SPACER type="block" width="1" height="243">/TD>

TD width=20 height=243>/TD>

TD width=24 height=243>/TD>

TD vAlign=top align=left width=496 colSpan=9 height=243 xpos="80">

TEXTAREA name=message rows=13 wrap=virtual cols=40>/TEXTAREA>/TD>

/TR>

TR height=157>

TD width=20 height=23>SPACER type="block" width="1" height="157">/TD>

TD width=20 height=23>/TD>

TD width=24 height=23>/TD>

TD width=14 height=23>/TD>

TD width=14 height=23>/TD>

TD vAlign=top align=left width=231 colSpan=5 height=23 xpos="112">

INPUT type=reset value=Clear>/TD>

TD vAlign=top align=left width=101 height=23 xpos="288">

INPUT type=submit value=Post name=submitButtonName>/TD>

TD width=128 height=23>/TD>

/TR>

/TBODY>/TABLE>/BODY>/HTML>



2。一个提交源码


$address = getenv("REMOTE_ADDR");

$filename = "$DOCUMENT_ROOT/view.txt";

$nam = stripslashes($name);

$topi = stripslashes($topic);

//echo $email;

$emai = stripslashes($email);

$messag = stripslashes($message);

$cnt = "




Name: $nam

n";

$cnt2 = "Topic: $topi

n";

$cnt3 = "Message: $messag

n";

$cnt4 = "IP: $address





nn";

$cnt5 = "EMail address: $emai

n";



$filed = @fopen($filename, "a+");

@fwrite($filed, "$cnt $cnt2 $cnt3 $cnt4 $cnt5");



fclose($filed);



$msg = "

Data Input complete

";

?>

html>

head>

title>Forum Posted/title>

/head>

body>

center>

table width="90%">

TBODY>

tr>td bgcolor="#aeaeae">FONT

face=Tahoma size=2>STRONG>~BBS~/STRONG>/FONT>/td>/tr>

tr>td bgcolor="#c0c0c0">font size="2" face="tahoma" color="#000000">




echo "$cnt";

echo "$cnt2";

echo "$cnt3";

echo "$cnt4";

echo "$cnt5" ?>

p>a href="view.php">View Entries Here!!!/a>/p>

?/BLOCKQUOTE>/font>/td>

/td>

/tr>

/table>

/center> /body>

/html>



3
.查看源码


$filename
= "$DOCUMENT_ROOT/view.txt";

$whattoread
= @fopen($filename, "r");

$file_cnt
= fread($whattoread, filesize($filename));



$msg
= "$file_cnt";

fclose
($whattoread);



?>

!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

html>

head>

title>BBS or Forum title here/title>

/head>

body>

DIV align=center>

TABLE style="HEIGHT: 113px; WIDTH: 420px">



TR>

TD bgcolor="#9999cc">/TD>

TD bgcolor="#9999cc">/TD>

TD bgcolor="#9999cc">/TD>/TR>

TR>

TD bgcolor="#9999cc">/TD>

TD bgcolor="#9999cc" height=16>

P align=center>BBS or Forum Title here/P> /TD>

TD bgcolor="#9999cc">/TD>/TR>

TR>

TD bgcolor="#9999cc">

/TD>

TD bgcolor="#9999cc">/TD>/TR>

TR>

TD bgcolor="#9999cc">/TD>

TD bgcolor="#9999cc">/TD>

TD bgcolor="#9999cc">/TD>/TR>/TABLE>/DIV>

/body>

/html>



这么样阿
就这么简单但我还是有点疑问这样的反复操作磁盘对系统有没有影响另外html页面可以比这个复杂但精华在不过如此



希望有兴趣的朋友可以在自己的论坛上试一下
看看效果如何



原作者
Daniel

来源
www.phpbuilder.c
相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板