0
目前我在考慮登錄腳本。想法 - 當您提交登錄名和密碼時,他們會檢查模型,如果登錄名和密碼正確,腳本會顯示有關完成登錄過程的消息。但是,如果我放入視圖echo $message;
並且我在登錄頁面,kohana顯示錯誤 - 未定義的變量$消息。但是,當我在頁面上,變量定義,所有工作。如何實現這個想法。有關登錄腳本的想法
編輯!
class Controller_About extends Controller_Template {
public function action_index() {
session_start();
if (isset($_SESSION['lietotajvards'])) {
if (!empty($_POST['virsraksts']) and !empty($_POST['saturs'])) {
$name = Model::factory('index')->insert_names($_POST['virsraksts'], $_POST['saturs']);
$result = $name;
$this->template->site_name = Kohana::$config->load('common')->get('site_name');
$this->template->site_description = Kohana::$config->load('common')->get('site_description');
$this->template->page_title = 'About';
$this->template->content = View::factory('about/about')->set('result', $result);
$this->template->styles[] = 'index/index';
} else {
$this->template->site_name = Kohana::$config->load('common')->get('site_name');
$this->template->site_description = Kohana::$config->load('common')->get('site_description');
$this->template->page_title = 'About';
$this->template->content = View::factory('about/about');
$this->template->styles[] = 'index/index';
}
} else {
if (!empty($_POST['lietotajvards']) and !empty($_POST['parole'])) {
$user_model = Model::factory('index')->valide($_POST['lietotajvards'], md5($_POST['parole']));
foreach ($user_model as $d) {
if ($_POST['lietotajvards'] == $d['lietotajvards'] and md5($_POST['parole']) == $d['parole']) {
$_SESSION['lietotajvards'] = $_POST['lietotajvards'];
$this->template->content = View::factory('login/index')->set('message', 'Ielogošanās veiksmīga!');
echo '<meta http-equiv="refresh" content="5" url="http://127.0.0.1/about">';
}
}
}
$this->template->site_name = Kohana::$config->load('common')->get('site_name');
$this->template->site_description = Kohana::$config->load('common')->get('site_description');
$this->template->page_title = 'About';
$this->template->content = View::factory('login/index');
$this->template->styles[] = 'index/index';
}
}}
我只有變量$消息的問題。
<?php echo $message; ?>
<form action="" method="post">
<input type="text" name="lietotajvards" id="" />
<input type="password" name="parole" id="" />
<input type="submit" value="Nosūtīt datus!" />
</form>
1.爲什麼要顯示消息而不重定向/顯示主頁? 2.向我們展示您遇到問題的代碼 – matino
您可以顯示「動作」,「模型」和「視圖」嗎? – vietean
請檢查我的編輯。 – reGative