我找不到php5的教材,用的是php4的教材,而我机子上装的是php5的环境,所以总是有各种各样的错误,一个小小的留言本折腾我好几天了,我把文件发上,大家帮我看看吧。
templates/index.tpl
nervebook2
访客留言本
| 访客:NAME |
E-Mail:EMAIL |
| 日期:DATE |
HomePage:HOMEPAGE |
| MESSAGE |
index.php
<?php
include("class.fasttemplate.php3");
include_once("DB.php");
$DSN = "mysql://root:mysql520@localhost/guestbook";
$myDB = new DB;
$tpl = new FastTemplate("templates/");
$tpl->define(array(main => "index.tpl"));
$tpl->define_dynamic("row","main");
$myOBJ = $myDB->connect($DSN);
if ($myDB->isError($myOBJ))
{
echo $myOBJ;
return;
}
$resultOBJ = $myOBJ->query("SELECT * FROM nervebook2");
if ($myDB->isError($resultOBJ))
{
echo $resultOBJ;
return;
}
while ($row = $resultOBJ->fetchRow())
{
$tmpDate = array(substr($row[2],0,4),substr($row[2],4,2),substr($row[2],6,2));
$tmpDate = array(substr($row[2],8,2),substr($row[2],10,2),substr($row[2],12,2));
$date = implode("-",$tmpDate)." ". implode(":",$tmpDate);
$tpl->assign(NAME, $row[1]);
$tpl->assign(DATE, $date);
$tpl->assign(EMAIL, $row[3]);
$tpl->assign(HOMEPAGE, $row[4]);
$tpl->assign(MESSAGE, nl2br($row[5]));
$tpl->parse(ROWS,".row");
}
$tpl->parse(BODY, "main");
$tpl->FastPrint("BODY");
?>
post.php
<?php
include_once("DB.php");
$date = date("Y-m-d H:i:s");
$DSN = "mysql://root:mysql520@localhost/guestbook";
$myDB = new DB;
$myOBJ = $myDB->connect($DSN);
if ($myDB->isError($myOBJ))
{
echo $myOBJ;
return;
}
$sql = "INSERT INTO nervebook2 (name, date, email, homepage, message) VALUES('$_POST[name]','$_POST[date]','$_POST[email]','$_POST[homepage]','$_POST[message]')";
$rusultOBJ = $myOBJ->query($sql);
if ($myDB->isError($resultOBJ))
{
echo $resultOBJ;
}else {
header("Location: index.php");
}
?>
还有class.FastTemplate.php3和post.php大家知道的,另外表就一张,大家看得出来的,
大家帮我看看到底还有哪里有错,小弟不胜感激!
大家也可以下载这几个文件。