Home >Backend Development >PHP Tutorial >php jquery 无刷新评说

php jquery 无刷新评说

WBOY
WBOYOriginal
2016-06-13 11:40:29707browse

php jquery 无刷新评论

php jquery 无刷新评论

刷新后删除一个小时前的记录

?

php jquery 无刷新评论
演示

?

?XML/HTML Code

?
  1. php??
  2. ??
  3. define('INCLUDE_CHECK',1);??
  4. require?"functions.php";??
  5. require?"conn.php";??
  6. ??
  7. ??
  8. //?remove?tweets?older?than?1?hour?to?prevent?spam??
  9. mysql_query("DELETE?FROM?add_delete_record?WHERE?id>1?AND?updatetimeSUBTIME(NOW(),'0?1:0:0')");??
  10. ??????
  11. //fetch?the?timeline??
  12. $q?=?mysql_query("SELECT?*?FROM?add_delete_record?ORDER?BY?ID?DESC");??
  13. ??
  14. $timeline='';??
  15. while($row=mysql_fetch_assoc($q))??
  16. {??
  17. ????$timeline.=formatTweet($row['text'],$row['updatetime']);??
  18. }??
  19. ??
  20. //?fetch?the?latest?tweet??
  21. $lastTweet?=?'';??
  22. ??
  23. ?>??
  24. ??
  25. html?PUBLIC?"-//W3C//DTD?XHTML?1.0?Transitional//EN"?"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">??
  26. html?xmlns="http://www.w3.org/1999/xhtml">??
  27. head>??
  28. meta?http-equiv="Content-Type"?content="text/html;?charset=utf-8"?/>??
  29. title>php?jquery?无刷新评论?www.freejs.nettitle>??
  30. ??
  31. link?rel="stylesheet"?type="text/css"?href="demo.css"?/>??
  32. script?type="text/javascript"?src="../../js/jquery-1.9.1.min.js">script>??
  33. script?type="text/javascript"?src="script.js">script>??
  34. ??
  35. ??
  36. head>??
  37. ??
  38. body>??
  39. ??
  40. div?id="twitter-container">??
  41. form?id="tweetForm"?action="submit.php"?method="post">??
  42. ??
  43. span?class="counter">140span>??
  44. label?for="inputField">请留言测试label>??
  45. ??
  46. textarea?name="inputField"?id="inputField"?tabindex="1"?rows="2"?cols="40">textarea>??
  47. input?class="submitButton?inact"?name="submit"?type="submit"?value="提交"?disabled="disabled"?/>??
  48. ??
  49. ??
  50. div?class="clear">div>??
  51. ??
  52. form>??
  53. ??
  54. h3?class="timeline">Freejs.neth3>??
  55. ??
  56. ul?class="statuses">php?echo?$timeline?>ul>??
  57. ??
  58. ??
  59. div>??
  60. ??
  61. body>??
  62. html>??

?functions.php

?

PHP Code
  1. ??
  2. if(!defined('INCLUDE_CHECK'))?die('You?are?not?allowed?to?execute?this?file?directly');??
  3. ??
  4. function?formatTweet($tweet,$updatetime)??
  5. {??
  6. ??
  7. ??
  8. ????$tweet=htmlspecialchars(stripslashes($tweet));??
  9. ????$flag?=?mt_rand(1,9);??
  10. ??
  11. ????return'?
  12. ????
  13. ?
  14. ????php jquery 无刷新评说.$flag.'.png"?width="48"? style="max-width:90%"?/>?
  15. ????
    ?
  16. ????demo?'.?preg_replace('/((?:http|https|ftp):\/\/(?:[A-Z0-9][A-Z0-9_-]*(?:\.[A-Z0-9][A-Z0-9_-]*)+):?(\d+)?\/?[^\s\"\']+)/i','$1',$tweet).'?
  17. ????
    '.strtotime($updatetime).'
    ?
  18. ????
?
  • ????
    ?
  • ????
  • ';??
  • ??
  • }??
  • ??
  • ?>??
  • submit.php

    PHP Code
    1. ??
    2. define('INCLUDE_CHECK',1);??
    3. require?"functions.php";??
    4. require?"conn.php";??
    5. ??
    6. ??
    7. if(ini_get('magic_quotes_gpc'))??
    8. $_POST['inputField']=stripslashes($_POST['inputField']);??
    9. ??
    10. ??
    11. ??
    12. $_POST['inputField']?=?mysql_real_escape_string(strip_tags($_POST['inputField']),$lr);??
    13. ??
    14. if(mb_strlen($_POST['inputField'])?1?||?mb_strlen($_POST['inputField'])>140)??
    15. die("0");??
    16. ??
    17. mysql_query("INSERT?INTO?add_delete_record?SET?text='".$_POST['inputField']."',updatetime=NOW()");??
    18. ??
    19. if(mysql_affected_rows($lr)!=1)??
    20. die("0");??
    21. ??
    22. echo?formatTweet($_POST['inputField'],time());??
    23. ??
    24. ?>??
    25. ?


    原文地址:http://www.freejs.net/article_biaodan_88.html

    Statement:
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
    Previous article:相关PHP回调函数的乌云Next article:「」关于PHP回调函数的疑问

    Related articles

    See more