php简单留言板代码

php简单留言板代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>php简单留言板代码</title>
</head>

<body>
<table width="98%" border="0">
<form id="form1" name="form1" method="post" action="comment/comment.php?nid=21">
  <tr>
    <td colspan="2">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="2">
      <label></label>
      <label>
      <textarea name="content" cols="40" rows="8" id="content"></textarea>
      </label>     
 </td>
  </tr>
  <tr>
    <td width="5%"><label>
      <input name="code" type="text" id="code" size="8" />
    </label></td>
    <td width="95%"><label><img src="../inc/code/encode.php" onclick="javascript:this.src='../inc/code/encode.php';"  />    </label>
输入验证码</td>
  </tr>
  <tr>
    <td colspan="2"><input type="submit" name="Submit" value="提交评论" /></td>
  </tr>
  </form>
</table>
$content = PostGet('content',1);
$tel = PostGet('tel',1);
$cname = PostGet('mail',1);
//$ip = getRealIp();

if( mb_strlen( $content ) > 100 || mb_strlen( $content )<5 )
{
 MessAge('留言内容长度5-100字符');
}
else if( strlen($tel) <5 && strlen( $tel )>15 )
{
 MessAge('联系电话错误!');
}
else if(!preg_match("/^([a-z0-9_.-]+)@([da-z.-]+).([a-z.]{2,6})$/",$cname))
{
 MessAge('输入正确的邮箱地址!');
}
else
{
 
 $date = date("Y-m-d H:i:s");
 $Db = new Db();
 $sql = "Insert into cn_loupan_news_comment(nid,content,datetime,cname,ip) values('0','$content','$date','$cname','$tel')";
  try{
   $Db->query( $sql );
   MessAge('谢谢你的建议,我们将尽快处理...!','/Complaints.php');
  }catch (Execption $e ){
   MessAge('发送信息失败!');
  }
}

function PostGet($str,$post=0)
 {
  empty($str)?die('para is null'.$str.'!'):'';
  if( $post )
  {
   return addslashes(htmlspecialchars(isset($_POST[$str])?$_POST[$str]:''));
  }
  else
  {
   return addslashes(htmlspecialchars(isset($_GET[$str])?$_GET[$str]:''));   
  }
 }
?>
</body>
</html>

时间: 2024-08-29 12:10:06

php简单留言板代码的相关文章

php自治简单留言板代码

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <?php $lianjie = mysql_connect("localhost","root","xiaolie") or die("连接失败"); mysql_query("set names utf8")

Go语言实现简单留言板的方法_Golang

本文实例讲述了Go语言实现简单留言板的方法.分享给大家供大家参考.具体实现方法如下: 复制代码 代码如下: package main import (     // "fmt"     "io"     "log"     "net/http"     "text/template"     "time"     "database/sql"     "gi

js使用DOM操作实现简单留言板的方法_javascript技巧

本文实例讲述了js使用DOM操作实现简单留言板的方法.分享给大家供大家参考.具体分析如下: 如图所示简易留言板,也就是自娱自乐版,说白了就是练习DOM操作. 要点一:document.createElement("标签名") 新建元素 要点二:父元素.appendChild("元素")  把新建的元素插入到页面的标签中(在标签的最后一个显示),这样才会在浏览器中显示出来 要点三:父元素.insertBefore("元素","要插入哪个元

jsp 网站开发-求解!留言板代码哪里错了!抓狂啊

问题描述 求解!留言板代码哪里错了!抓狂啊 这段代码哪里出错了!这是一段留言板提交留言到数据库的代码,可是实验显示不能正确提交到数据库!求解!代码主体: <% String sql;String name=request.getParameter("name");if(name==null) {name=""; }String mail=request.getParameter("mail");if(mail==null) {mail=&q

php mysql留言板代码

  <form name="form1" method="post" action="">   <label>   <input type="text" name="tp_nam">   </label>   <label>   <input type="submit" name="Submit" va

js使用DOM操作实现简单留言板的方法

 如图所示简易留言板,也就是自娱自乐版,说白了就是练习DOM操作. 要点一:document.createElement("标签名") 新建元素 要点二:父元素.appendChild("元素") 把新建的元素插入到页面的标签中(在标签的最后一个显示),这样才会在浏览器中显示出来 要点三:父元素.insertBefore("元素","要插入哪个元素的前面") 把新建的元素插入到页面中指定的标签前面,这样后面输入的内容才会显示到

php 简单留言板教程一

作留言板我们来看看下面图片上的文件是指那些吧, global.php是全局文件有数据链接代码.index.php是显示文件不用多说了下面有讲解的,login.php登录文件,logout.php退出登录,madd.php 增加留言,mreplay.php回答留言,好了我们先来看看global.php文件的代码吧. <?php  @header("content-Type: text/html; charset=UTF-8");  $dbhost = 'localhost';//数

php 简单留言板教程三

好了,其它的都快完了我们就来看看index.php文件显示留方的页面吧. <?php  @session_start();  include("global.php");    if(isset($_GET['act']) && $_GET['act'] == 'del')  {   if(isset($_GET['mid']))   {    $mid = intval($_GET['mid']);    if(mysql_query("DELETE

php 简单留言板教程二

好了现在我们来看login.php文件的程序代码吗. <?php  session_start();  include("global.php");    if(isset($_POST['username']) && isset($_POST['pwd']))  {   $result = mysql_query("SELECT * FROM xx_admin");   if($info = mysql_fetch_array($result