• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

php jquery 无刷新评说

php 搞代码 3年前 (2022-01-24) 19次浏览 已收录 0个评论

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?updatetime<SUBTIME(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. <!DOCTYPE?html?PUBLIC?"-//W3C//DTD?XHTML?1.0?Transitional//EN"?"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;>??
  26. <html?xmlns=http://www.w3.org/1999/xhtml&#8221;>??
  27. <head>??
  28. <meta?http-equiv=“Content-Type”?content=“text/html;?charset=utf-8”?/>??
  29. <title>php?jquery?无刷新评论?www.freejs.net</title>??
  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”>140</span>??
  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.net</h3>??
  55. ??
  56. <ul?class=“statuses”><?php?echo?$timeline?></ul>??
  57. ??
  58. ??
  59. </div>??
  60. ??
  61. </body>??
  62. </html>??

?functions.php

?

PHP Code

  1. <?php??
  2. ??
  3. if(!defined(‘INCLUDE_CHECK’))?die(‘You?are?not?allowed?to?execute?this?file?directly’);??
  4. ??
  5. function?formatTweet($tweet,$updatetime)??
  6. {??
  7. ??
  8. ??
  9. ????$tweet=htmlspecialchars(stripslashes($tweet));??
  10. ????$flag?=?mt_rand(1,9);??
  11. ??
  12. ????return?
  13. ????
  14. ?
  15. ????.$flag.‘.png”?width=”48″?height=”48″?/>?
  16. ????
    ?
  17. ????demo?’.?preg_replace(‘/((?:http|https|ftp):\/\/(?:[A-Z0-9][A-Z0-9_-]*(?:\.[A-Z0-9][A-Z0-9_-]*)+):?(\d+)?\/?[^\s\”\’]+)/i’,‘$1’,$tweet).?
  18. ????
    ‘.strtotime($updatetime).

    ?

  19. ????

?

  • ????

    ?

  • ????
  • ‘;??

  • ??
  • }??
  • ??
  • ?>??
  • submit.php

    PHP Code

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


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


    搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
    转载请注明原文链接:php jquery 无刷新评说
    喜欢 (0)
    [搞代码]
    分享 (0)
    发表我的评论
    取消评论

    表情 贴图 加粗 删除线 居中 斜体 签到

    Hi,您需要填写昵称和邮箱!

    • 昵称 (必填)
    • 邮箱 (必填)
    • 网址