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