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


PHP Dao::redirect方法代碼示例

本文整理匯總了PHP中Dao::redirect方法的典型用法代碼示例。如果您正苦於以下問題:PHP Dao::redirect方法的具體用法?PHP Dao::redirect怎麽用?PHP Dao::redirect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Dao的用法示例。


在下文中一共展示了Dao::redirect方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: Dao

<?php

if (!isset($_SESSION)) {
    session_start();
}
require_once "classes/dao.php";
if (isset($_POST["username"]) && isset($_POST["password"]) && isset($_POST["email"])) {
    $username = $_POST["username"];
    $password = $_POST["password"];
    $email = $_POST["email"];
    try {
        $dao = new Dao();
        if ($dao->newUser($username, $password, $email)) {
            $_SESSION["name"] = $username;
            if (isset($_POST['rememberme']) && $_POST['rememberme']) {
                $expireTime = time() + 60 * 60 * 24 * 180;
                # 180 days from now
                setcookie("username", $_SESSION["name"], $expireTime);
            }
            $dao->redirect("../index.php", "Welcome to idleg, {$username}!");
        } else {
            $dao->redirect("../index.php", "User setup failed.");
        }
    } catch (Exception $e) {
        var_dump($e);
        die;
    }
}
開發者ID:paleomedia,項目名稱:idleg_flask,代碼行數:28,代碼來源:newuser.php

示例2: Dao

<?php

if (!isset($_SESSION)) {
    session_start();
}
require_once "classes/dao.php";
if (isset($_POST["username"]) && isset($_POST["password"])) {
    $name = $_POST["username"];
    $password = $_POST["password"];
    try {
        $dao = new Dao();
        if ($dao->check_login($name, $password)) {
            $_SESSION["name"] = $name;
            if ($_POST['rememberme'] = 1) {
                $expireTime = time() + 60 * 60 * 24 * 180;
                # 180 days from now
                setcookie("username", $_SESSION["name"], $expireTime);
            }
            $dao->redirect("../index.php", "Login successful! Welcome back, {$name}.");
        } else {
            $dao->redirect("../index.php", "Incorrect user name and/or password.");
        }
    } catch (Exception $e) {
        var_dump($e);
        die;
    }
}
開發者ID:paleomedia,項目名稱:idleg_flask,代碼行數:27,代碼來源:login.php

示例3: 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");
開發者ID:paleomedia,項目名稱:idleg_flask,代碼行數:25,代碼來源:handler.php


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