奶头挺立呻吟高潮av全片,成人试看120秒体验区,性欧美极品v,A片高潮抽搐揉捏奶头视频

php語言

php+ajax實(shí)現(xiàn)無刷新的新聞留言系統(tǒng)

時(shí)間:2024-09-26 16:35:44 php語言 我要投稿
  • 相關(guān)推薦

php+ajax實(shí)現(xiàn)無刷新的新聞留言系統(tǒng)

  文章主要介紹了一款基于php+ajax無刷新的新聞留言系統(tǒng)實(shí)現(xiàn)過程,感興趣的小伙伴們可以參考一下。

php+ajax實(shí)現(xiàn)無刷新的新聞留言系統(tǒng)

  本文介紹了一款無刷新的新聞留言系統(tǒng),最簡(jiǎn)明易懂的一個(gè)ajax無刷新留言系統(tǒng),源碼中省略了接受數(shù)據(jù)驗(yàn)證的過程,大家可根據(jù)自己的需求進(jìn)行擴(kuò)展,下面進(jìn)入主題。

  核心源碼:

  1.配置文件:config.php,代碼如下:

  ?

  1

  2

  3

  4

  5

  6

  7

  8

  9

  10

  11

  <?php

  //數(shù)據(jù)庫配置信息(用戶名,密碼,數(shù)據(jù)庫名,表前綴等)

  $cfg_dbhost = "localhost";

  $cfg_dbuser = "root";

  $cfg_dbpwd = "root";

  $cfg_dbname = "ajaxdemo1";

  $cfg_dbprefix = "";

  $link = mysql_connect($cfg_dbhost,$cfg_dbuser,$cfg_dbpwd);

  mysql_select_db($cfg_dbname);

  mysql_query("set names utf8");

  ?>

  2.處理請(qǐng)求:deal.php,代碼如下:

  ?

  1

  2

  3

  4

  5

  6

  7

  8

  9

  10

  11

  12

  <?php

  header("Content-type:text/html;charset=utf-8");

  include "config.php";

  //post接收數(shù)據(jù),只是演示效果,這里就省去驗(yàn)證了

  $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.首頁代碼:index.php,代碼如下:

  ?

  1

  2

  3

  4

  5

  6

  7

  8

  9

  10

  11

  12

  13

  14

  15

  16

  17

  18

  19

  20

  21

  22

  23

  24

  25

  26

  27

  28

  29

  30

  31

  32

  33

  34

  35

  36

  37

  38

  39

  40

  41

  42

  43

  44

  45

  46

  47

  48

  49

  <!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=utf-8" />

  <title>無刷新</title>

  <link href="css/css.css" type="text/css" rel="stylesheet" />

  <style type="text/css">

  body{color:#555;font-size:14px;padding:0;margin:0;}

  #form { background:#dedede; padding:10px 20px; width:300px;}

  #show{ background:#f6f6f6;padding:10px 20px; width:300px;}

  #show p{ margin:6px; font-size:13px; line-height:22px; border-bottom:1px dashed #cdcdcd;}

  </style>

  <script type="text/javascript" src="jquery-1.7.2.min.js"></script>

  <script type="text/javascript">

  $(function(){

  $("#sub").click(function(){

  //只是說明原理,然后這里省去了驗(yàn)證文本框內(nèi)容的步驟,直接發(fā)送ajax請(qǐng)求

  $.post("deal.php",{name : $("#name").val(), content : $("#content").val()}, function(data){

  if(data.status){

  var str = "<p><strong>"+data.name+"</strong> 發(fā)表了:"+data.content+"</p>";

  $("#show").prepend(str); //在前面追加

  }else{

  alert("評(píng)論失敗");

  }

  }, 'json');

  });

  });

  </script>

  </head>

  <body>

  <p id="form">

  <form action="deal.php" method="get" id="suggest_form">

  用戶名:<input type="text" name="name" id="name" /><br/>

  內(nèi)  容:<textarea name="content" id="content"></textarea>

  <input type="button" value="發(fā)布" id="sub" />

  </form>

  </p>

  <p id="show">

  <?php

  include "config.php";

  $sql = "select * from test;";

  $res = mysql_query($sql,$link);

  while($row=mysql_fetch_array($res)){

  echo "<p><strong>".$row['name']."</strong> 發(fā)表了:".$row['content']."</p>";

  }

  ?>

  </p>

  </body>

  </html>

  數(shù)據(jù)庫文件,代碼如下:

  ?

  1

  2

  3

  4

  5

  6

  7

  DROP TABLE IF EXISTS `test`;

  CREATE TABLE `test` (

  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,

  `name` varchar(64) NOT NULL,

  `content` text NOT NULL,

  PRIMARY KEY (`id`)

  ) ENGINE=MyISAM DEFAULT CHARSET=utf8;

  以上就是為大家分享的php+ajax實(shí)現(xiàn)無刷新的新聞留言系統(tǒng),希望對(duì)大家的學(xué)習(xí)有所幫助。

【php+ajax實(shí)現(xiàn)無刷新的新聞留言系統(tǒng)】相關(guān)文章:

php+ajax實(shí)現(xiàn)無刷新數(shù)據(jù)分頁例子07-31

基于PHP+Ajax實(shí)現(xiàn)表單驗(yàn)證的詳解08-22

html無刷新分頁前端代碼08-20

JAVA實(shí)現(xiàn)電子商務(wù)系統(tǒng)09-25

Java網(wǎng)上考試系統(tǒng)的設(shè)計(jì)和實(shí)現(xiàn)05-30

淺談組件機(jī)制與操作系統(tǒng)的實(shí)現(xiàn)07-26

javasc ript 返回上一頁及刷新頁面的實(shí)現(xiàn)方法08-02

C語言如何實(shí)現(xiàn)ATM機(jī)存取款系統(tǒng)09-13

win7系統(tǒng)清除冗余dll文件的實(shí)現(xiàn)方法10-18

Windows10系統(tǒng)刪除Windows憑據(jù)實(shí)現(xiàn)方法08-11

主站蜘蛛池模板: 安塞县| 平泉县| 陆丰市| 琼结县| 吴桥县| 临朐县| 疏附县| 海晏县| 鲁山县| 株洲市| 临高县| 通海县| 黄梅县| 阳春市| 修水县| 肥城市| 开阳县| 达州市| 安顺市| 普安县| 定南县| 乌拉特前旗| 沐川县| 中方县| 屏南县| 卢氏县| 北宁市| 含山县| 内丘县| 富宁县| 平阴县| 霍林郭勒市| 宁晋县| 广河县| 南岸区| 桐乡市| 且末县| 屏南县| 班玛县| 白山市| 普安县|