A simple ajax|jquery implementation of the message board (without security verification)

Source: Internet
Author: User
Tags button type

Disclaimer: Currently the program 0.0 version is only experimental, and does not process user input, in the 1.0 program to add the following features:

1. Regular matching verification email,url

2. Special character escape, filtration

3. Add Verification Code function


List of programs:

The core part of the 1.index.php code is AJAX in the <script></script> tag. See http://api.jquery.com/jQuery.ajax/

By passing a value to the post.php, and then using $ (' #messages '). Load ("messages.php") Update id = Messages DIV in Ajax way

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">  

2.post.php

<?php include ("config.php"); if (isset ($_post[' name ')) {$name = $_post[' name '];}
else{$name = "";} if (isset ($_post[' email ')) {$email = $_post[' email '];}

else{$email = "";} if (Isset ($_post[' Captcha_code ')) {$security _code = $_post[' Captcha_code '];}

else{$security _code = "";} if (isset ($_post[' website ')) {$website = $_post[' website '];}
else{$website = "";}
if ($website = = ' http://') {$website = "";}
	if ($website!= ') {//if (Strpos ($website, "http://") ==false) {//$website = "http://". $website; } if (Isset ($_post[' message ')) {$message = $_post[' message '];}

else{$message = "";}

$ip =$_server[' remote_addr ']; $insert = "INSERT into Message_board (name, email, URLs, post_date, message, ip_address) VALUES (' $name ', ' $email ', ' $website

', now (), ' $message ', ' $ip '); $mysql _insert = mysql_query ($insert) or Die ("<b>a fatal MySQL error occured</b>.\n<br/>query:". $query. "<br/>\nerror: (". Mysql_errno (). ") " .
Mysql_error ());

Exit ?>
 
3.messages.php

?

PHP require_once (' config.php '); echo "<p>messages loaded:". Date ("D/m/y:h:i:s", Time ()). "

</p> "; if (isset ($_get[' offset ')) {$offset = $_get[' offset '];

else{$offset = 0;}

$numresults =mysql_query ("SELECT * from Message_board");

$numrows =mysql_num_rows ($numresults) or Die ("currently you don't have any items.");
$query = "SELECT * from Message_board ORDER BY id desc limit $offset, $limit";//pagination $result =mysql_query ($query);
$num =mysql_num_rows ($result);

Mysql_close ();

echo " 




Related Article

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.