本文整理汇总了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");