>  기사  >  백엔드 개발  >  php制作的bbs超经典

php制作的bbs超经典

WBOY
WBOY원래의
2016-07-25 08:48:361215검색
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. ?>
复制代码


성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.