PHP Simple Message Board Code

Source: Internet
Author: User
Tags strlen

PHP Simple Message Board Code
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<title>php Simple message Board code </title>

<body>
<table width= "98%" border= "0" >
<form id= "Form1" Name= "Form1" method= "Post" action= "comment/comment.php?nid=21" >
<tr>
&LT;TD colspan= "2" >&nbsp;</td>
</tr>
<tr>
&LT;TD colspan= "2" >
<label></label>
<label>
<textarea name= "Content" cols= "rows=" "8" id= "Content" ></textarea>
</label>
</td>
</tr>
<tr>
&LT;TD width= "5%" ><label>
<input name= "Code" type= "text" id= "code" size= "8"/>
</label></td>
&LT;TD width= "The ><label> </label>
Input Verification Code </td>
</tr>
<tr>
&LT;TD colspan= "2" ><input type= "Submission" name= "submit" value= "submitted comments"/></td>
</tr>
</form>
</table>
$content = postget (' content ', 1);
$tel = Postget (' tel ', 1);
$cname = Postget (' Mail ', 1);
$ip = Getrealip ();

If (Mb_strlen ($content) > | | mb_strlen ($content) <5)
{
 message (' message length 5-100 characters ');
}
Else if (strlen ($tel) <5 && strlen ($tel) >15)
{
 message (' Contact phone error! ')
}
Else if (!preg_match (/^) ([a-z0-9_.-]+) @ ([da-z.-]+). ( [A-Z.] {2,6}) $/", $cname))
{
 message (' Enter the correct email address! ');
}
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 (' Thank you for your advice, we'll deal with it as soon as possible ...! ', '/complaints.php ');
  }catch (execption $e) {
   message (' Send message failed! ');
  }
}

Function Postget ($str, $post =0)
 {
  empty ($str)? Die (' Para is null '. $str. '! '): ';
  if ($post)
  {
   return addslashes (Htmlspecialchars (isset STR])? $_post[$str]: ");
  }
  else
  {
   return addslashes htmlspecialchars (isset ($_GET[$str] ) $_get[$str]:    
  
 

</body>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.