示例#1
0
文件: news.php 项目: denson7/phpstudy
<?php

header("content-type:text/html;charset=utf-8");
include_once 'dbio/NewsTypes.php';
include_once 'dbio/NewsArticles.php';
include_once 'dbio/Reviews.php';
//获得url中的新闻编号
$articleId = $_GET["articleId"];
//获得表单提交的数据(评论)
$face = $_POST["face"];
$content = $_POST["content"];
$userName = $_POST["userName"];
//添加评论
if ($content != NULL) {
    $result = Reviews::addReviews($articleId, $face, $content, $userName);
    if ($result > 0) {
        echo "<script type='text/javascript'>";
        echo "\talert('发表评论成功!');";
        echo "\twindow.location='news.php?articleId={$articleId}';";
        echo "</script>";
    } else {
        echo "<script type='text/javascript'>";
        echo "\talert('发表评论失败!');";
        echo "\twindow.location='news.php?articleId={$articleId}';";
        echo "</script>";
    }
}
//获得当前页面显示的新闻
$result3 = NewsArticles::getNewsById($articleId);
//所有分类
$newsTypes = NewsTypes::getNewsTypes();