教程集 www.jiaochengji.com
教程集 >  脚本编程  >  php  >  正文 php+dbfile开发小型留言本

php+dbfile开发小型留言本

发布时间:2016-12-04   编辑:jiaochengji.com
教程集为您提供php+dbfile开发小型留言本等资源,欢迎您收藏本站,我们将为您提供最新的php+dbfile开发小型留言本资源
board.php用来存储数据,可以先在里面添加了一条留言纪录。
代码
<?php
$Board=array(
array(1081410332,'测试','测试留言本','http://www.piscdong.com')
);
?>
index.php是留言显示和提交页面。
代码
<?php
require_once('board.php');
function htmlencode($content){
$content=htmlspecialchars($content);
$content=preg_replace("/ /i","<br />",$content);
return $content;
}
if($HTTP_SERVER_VARS['REQUEST_METHOD']=='POST'){
$configpath_parts1 = pathinfo($SCRIPT_FILENAME);
$time=time();
$name=$HTTP_POST_VARS['name'];
$url=(preg_match("/^[w-] (.[w-] )*@[w-] (.[w-] ) $/i",$HTTP_POST_VARS['url']) || $HTTP_POST_VARS['url']=='')?$HTTP_POST_VARS['url']:'http://'.htmlspecialchars(preg_replace("/https?:///i",'',$HTTP_POST_VARS['url']),ENT_QUOTES);
$info=htmlencode($HTTP_POST_VARS['info']);
if($name!='' && $info!=''){
$Board[]=array($time,$name,$info,$url);
}
for($i=0;$i<count($Board);$i ){
$bd=current($Board);
$s[]=" array(".$bd[0].",'".$bd[1]."','".$bd[2]."','".$bd[3]."')";
next($Board);
}
$content="<?php $Board=array( ".join($s,", ")." ); ?>";
$filename=$configpath_parts1['dirname'].'/'.'board.php';
if(is_writable($filename) || !file_exists($filename)){
if(!$handle=fopen($filename,'w')){
return false;
}
if(!fwrite($handle,$content)){
return false;
}
fclose($handle);
}else{
return false;
}
header('Location:.');
}else{
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>留言本</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
</head>
<body>
<form method="post" name="form1" action="">
<table border="0" cellspacing="5" cellpadding="0" align="center">

您可能感兴趣的文章:
php+dbfile开发小型留言本
php留言板功能模块有哪些
web开发用python还是php?
php是哪种类型语言?
php xml留言板实例教程一
新手建议学php吗?
php语言的发展历史
php可以开发游戏吗?
php除了网站能做什么
php web与python web哪个好

[关闭]
~ ~