当前位置:Gxlcms > PHP教程 > php制作的bbs超经典

php制作的bbs超经典

时间:2021-07-01 10:21:17 帮助过:22人阅读

php制作的bbs超经典(全文在这里)http://115.com/lb/5lbcqol0flze
  1. $dsn = "mysql:host=localhost;dbname=数据库名";
  2. $dbh = new PDO($dsn, '用户名', '密码', array(PDO::ATTR_PERSISTENT => true));
  3. $dbh -> query("SET NAMES 'utf8'; ");
  4. $id=$_POST['id'];
  5. $username = $_SESSION['username']; //获取回帖人的相关信息
  6. $sql = "select * from user where username= '$username'";
  7. $result = mysql_query($sql);
  8. $row = mysql_fetch_array($result);
  9. $row['score']=$row['score']+2;
  10. mysql_query("update user set score = '".$row['score']."' where username ='".$row['username']."'");
  11. $content = $_POST['content'];//获取回帖的相关信息
  12. //$email = $row['email'];
  13. $date = date("Y-m-d H:i:s");
  14. $date=date("y-m-d H:i");
  15. date_default_timezone_set("Asia/Shanghai");
  16. $time = date('Y-m-d H:m:s');
  17. $y=date("Y",strtotime($time));
  18. $m=date("m",strtotime($time));
  19. $d=date("d",strtotime($time));
  20. $h=date("H",strtotime($time));
  21. $w=date("w",strtotime($time));
  22. //$weekNumber=intval(date('W'));
  23. //$url = "http://api.map.baidu.com/geocoder?location={$weidu},{$jingdu}&output=json";
  24. //$json = json_decode(file_get_contents($url), TRUE);
  25. //$a=file_get_contents($url);
  26. //$province = $json['result']['addressComponent']['province'];
  27. //$city = $json['result']['addressComponent']['city'];
  28. $sql=" insert into 表名(文章ID,内容, 名字, 时间)values('$id', '$content', '$username', now())";
  29. //$result=mysql_query($sql);
  30. if ($dbh -> query($sql)) {
  31. header("Content-Type:Application/json");
  32. $arr = array('status' => 'ok');
  33. echo json_encode($arr);
  34. }
  35. ?>

人气教程排行