本文整理匯總了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;
}
}
示例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;
}
}
示例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");