本文整理汇总了PHP中CUser::login方法的典型用法代码示例。如果您正苦于以下问题:PHP CUser::login方法的具体用法?PHP CUser::login怎么用?PHP CUser::login使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CUser
的用法示例。
在下文中一共展示了CUser::login方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: CUser
<?php
/**
* This is a Orange pagecontroller.
*
*/
// Include the essential config-file which also creates the $Orange variable with its defaults.
include __DIR__ . '/config.php';
$Orange['title'] = "Startsida";
$message = "";
if (isset($_POST['username']) && isset($_POST['password'])) {
$username = $_POST['username'];
$password = $_POST['password'];
$user = new CUser();
$res = $user->login($username, $password);
if ($res) {
$user->setSessionVariablesAtLogin($res);
$name = $user->getName();
header('Location: login.php');
} else {
$message = "Wrong username or password";
}
}
if (CUser::isAuthenticated()) {
$message = "<p>Inloggad som: " . CUser::getName();
$Orange['main'] = <<<EOD
<h1></h1>
<fieldset>
<legend>Login</legend>
<p>{$message}</p>
示例2: CUser
<?php
/**
* This is a Branax pagecontroller.
*
*/
// Include the essential config-file which also creates the $branax variable with its defaults.
include __DIR__ . '/config.php';
// Create the user object
$user = new CUser($branax['database']);
// Check if user is authenticated.
$output = $user->isAuthenticated() ? "Du är inloggad som: {$user->getAcronym()} ({$user->getName()})" : "Du är INTE inloggad.";
// Check if user and password is okey and login the user
if (isset($_POST['login'])) {
$user->login($_POST['acronym'], $_POST['password']);
header('Location: user_status.php');
}
// Do it and store it all in variables in the Branax container.
$branax['title'] = "Login";
$branax['main'] = <<<EOD
<h1>{$branax['title']}</h1>
<form method=post>
<fieldset>
<legend>Login</legend>
<p><label>Användare:<br/><input type='text' name='acronym' value=''/></label></p>
<p><label>Lösenord:<br/><input type='password' name='password' value=''/></label></p>
<p><input type='submit' name='login' value='Login'/></p>
<p><a href='user_logout.php'>Logout</a></p>
<p><a href='user_register.php'>Skapa ny användare</a></p>
<output><b>{$output}</b></output>