一个很简单的php留言板。筹建在sae上的。
一个很简单的php留言板。。。。搭建在sae上的。。。我在sae上搭建了一个个人简历的页面: 有兴趣的可以访问 http://671coder.sinaapp.com/
在做下面一个简单的留言板的时候,卡了我很久,虽然完全没用过php。。但是还是最后勉强写出来了。。。
主页面html是这样写的:
Contact Me
This block can be hidden and only shown in a popup.
验证码功能暂时还没有实现。。。
后台的php是这样写的:
《script》 alert("Sorry, your name and your message can not be empty."); window.history.back(-1); 《script》 } $m_notchar="$#@!%&*?<>"; $mysql = new SaeMysql(); $judge = true; for ($i=0; $i<10; $i++) { if (strpos($name, substr($m_notchar, $i, 1)) || strpos($message, substr($m_notchar, $i, 1))) $judge = false; } if( $mysql->errno() != 0 ) { die( "Error:" . $mysql->errmsg() ); } else if (!$judge) { ?>《script》alert("Sorry, your message has illegal characters, please re-enter checked.");《script》 } else { $sql = "INSERT INTO Message (MName, MText) VALUES ('$name', '$message')"; $mysql->runSql( $sql ); ?>《script》alert("Thank you for your message!");《script》 } $mysql->closeDb(); ?> 《script》window.history.back(-1);《script》
然后最后显示留言板是这么写的:
My messages
-
echo "
-
=$user?>:
=$text?>
671coder's message:
"; while ($r = mysql_fetch_array($result)) { $idx = $r["MId"]; $user = $r["MName"]; $text = $r["MText"]; ?>
怎么样!感觉上很炫吧!
数据库的话想必大家都知道是怎么设计的了吧?!
PHP之友评论