本文整理匯總了PHP中post::findPost方法的典型用法代碼示例。如果您正苦於以下問題:PHP post::findPost方法的具體用法?PHP post::findPost怎麽用?PHP post::findPost使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類post
的用法示例。
在下文中一共展示了post::findPost方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: post
require_once "models/PasswordHash.php";
require_once "models/post.php";
session_start();
//Make sure the user is logged in
if (isset($_SESSION['user'])) {
$user = $_SESSION['user'];
} else {
die;
}
//If they aren't an admin they aren't allowed here either
if ($user->admin != 2) {
die;
}
//If they are authorized to be here, make a class object to handle the post
$post = new post();
//If the id is set in the query string, do the following
if (isset($_GET['id'])) {
//First find the post in the database
$page = $post->findPost($dbh, $_GET['id']);
//If it doesn't exist, kill the page
if (!$page) {
die;
} else {
//And then send them back to the main page
$post->deletePost($dbh, $page->id);
header("Location: /");
die;
}
} else {
die;
}
示例2: header
$user = $_SESSION['user'];
} else {
header("Location: loginCheckCtrl");
die;
}
//If they are logged in but not an admin kill the page
if ($user->admin != 2) {
die;
}
//Create the flags and class object
$post = new post();
$error = true;
$sent = false;
if (isset($_GET['id'])) {
$id = $_GET['id'];
$postToEdit = $post->findPost($dbh, $id);
//If that post doesn't exist, just kill the page
if (!$postToEdit) {
die;
}
} else {
die;
}
//Otherwise let them edit the post.
if ($_POST) {
if (isset($_POST['title'])) {
if (empty($_POST['title'])) {
$error = false;
}
} else {
$error = false;