本文整理汇总了PHP中Dao::saveComment方法的典型用法代码示例。如果您正苦于以下问题:PHP Dao::saveComment方法的具体用法?PHP Dao::saveComment怎么用?PHP Dao::saveComment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dao
的用法示例。
在下文中一共展示了Dao::saveComment方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Dao
<?php
// handler.php
// handle comment posts, saving to MySQL and redirecting back to the list
if (!isset($_SESSION)) {
session_start();
}
require_once "classes/dao.php";
if (isset($_SESSION["name"]) && isset($_POST["commentButton"])) {
$comment = $_POST["comment"];
$comment_type = $_POST["vote"];
$bill = $_POST["bill"];
$username = $_SESSION["name"];
try {
$dao = new Dao();
$dao->saveComment($username, $comment, $bill, $comment_type);
} catch (Exception $e) {
var_dump($e);
die;
}
} else {
$dao = new Dao();
$dao->redirect("../index.php", "Please log in to comment.");
}
header("Location:../index.php");
示例2: clean_input
<?php
session_start();
require_once $_SERVER['DOCUMENT_ROOT'] . "/resources/Dao.php";
$dao = new Dao();
$user = $dao->getUser($_SESSION["email"]);
$user_id = $user["id"];
$content = clean_input($_POST["content"]);
$post_id = $_POST["post_id"];
$id = $dao->saveComment($user_id, $post_id, $content);
function clean_input($data)
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="refresh" content="0; url=<?php
echo $_SERVER['HTTP_REFERER'];
?>
" />
</head>
<body>
<h1>
</h1>
示例3: Dao
<?php
// handler.php
// handle comment posts, saving to MySQL and redirecting back to the list
require_once "Dao.php";
if (isset($_POST["commentButton"])) {
$comment = $_POST["comment"];
try {
$dao = new Dao();
$dao->saveComment($comment);
} catch (Exception $e) {
var_dump($e);
die;
}
}
header("Location:index.php");
?>