欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

php制作的bbs超经典

程序员文章站 2022-04-10 17:48:46
...
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. ?>
复制代码