Php + ajax implements a refreshing news and message system _ PHP

Source: Internet
Author: User
This article mainly introduces the implementation process of a new news and message system based on php + ajax. interested friends can refer to this article to introduce a new news and message system, the most concise and easy-to-understand ajax No-refreshing message system, the source code ignores the process of accepting data verification, you can expand according to your own needs, next to the topic.

Core source code:

1. configuration file: config. php. the code is as follows:

<? Php // database configuration information (username, password, database name, table prefix, etc.) $ pai_dbhost = "localhost"; $ pai_dbuser = "root"; $ pai_dbpwd = "root "; $ response _dbname = "ajaxdemo1"; $ response _dbprefix = ""; $ link = mysql_connect ($ response _dbhost, $ response _dbuser, $ response _dbpwd); mysql_select_db ($ response _dbname ); mysql_query ("set names utf8");?>

2. process the request: deal. php. the code is as follows:

<? Php header ("Content-type: text/html; charset = utf-8"); include "config. php "; // post receives data, but only demonstrates the effect. here, you do not need to verify $ name =$ _ POST ['name']; $ content = $ _ POST ['content']; $ SQL = "insert into test (name, content) values ('{$ name }', '{$ content}'); "; $ res = mysql_query ($ SQL, $ link); if ($ res) {echo '{" name ":"'. $ name. '"," content ":"'. $ content. '"," status ":" 1 "}';}?>

3. homepage code: index. php. the code is as follows:

   
  Refreshing 
   

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.