资源描述:
《[计算机]php教程训练》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、第1章PHP概述国程序7-1文件名:setup.php//数据库服务器$dbserver="localhost";//数据库名$databasename="";//用户名$dbusername="";//口令$dbpassword="";//每页显示的记录数$intPagesize=10;//颜色定义$mancolor="#000000";$womancolor="#ff66ff";$noknowcolor="blue";//管理员口令。$adminpassword=""//修改留言的超级口令,通过此口令可修改任何人留言。$modipa
2、ssword=""?>程序7-2文件名:pageheader.html//产生留言板的主页面//通过图片方式,显示“请你留言”4个字
写新留言 –25–第1章PHP概述国3、f=guestbook.php>查看留言 搜索留言 返回首页
程序7-3文件名:write.php4、s"," ",$Text);$Text=preg_replace("/[h1](.+?)[/h1]/is","
\1
",$Text);$Text=preg_replace("/[h2](.+?)[/h2]/is","\1
",$Text);$Text=preg_replace("/[h3](.+?)[/h3]/is","\1
",$Text);$Text=preg_replace("/[h4](.+?)[/h4]/is","\1
5、>",$Text);$Text=preg_replace("/[h5](.+?)[/h5]/is","
\1
",$Text);$Text=preg_replace("/[h6](.+?)[/h6]/is","\1
",$Text);$Text=preg_replace("/[url](.+?)[/url]/is","\1",$Text);$Text=preg_replace("/[url=(.+?)](.*)[/url]/is","<
6、ahref=\1>\2",$Text);$Text=preg_replace("/[img](.+?)[/img]/is","",$Text);$Text=preg_replace("/[b](.+?)[/b]/is","\1",$Text);$Text=preg_replace("/[email](.+?)[/email]/is","\1",$Text);$Text=preg_replace("/[i](.+?)[/i
7、]/is","\1",$Text);return$Text;}$error="";//若用户点击命令按钮【写完了】,执行下面的代码,负责将留言信息写入数据表中if($cmd=="savepost"){if($txtName==""
8、
9、$txtContent==""
10、
11、$txtpwd==""){–25–第1章PHP概述国$error="请输入您的大名和留言、密码!";}else{/*若将php.ini中magic-quotes-gpc设置为on,系统会自动将“'”转换为“”,同时MySQL还需要将“'”转化为“''”。*/
12、$txtName=ubbcode(ereg_replace("'","''",$txtName));$txtFrom=ereg_replace("'","''",$txtFrom