當前位置: 首頁>>代碼示例>>PHP>>正文


PHP post::findPost方法代碼示例

本文整理匯總了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;
}
開發者ID:kelmo2,項目名稱:leagueOfLegendsClubSite,代碼行數:31,代碼來源:deletePost.php

示例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;
開發者ID:kelmo2,項目名稱:leagueOfLegendsClubSite,代碼行數:31,代碼來源:editPost.php


注:本文中的post::findPost方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。