0
로그인 스크립트에 대해 생각합니다. 아이디어 - 로그인과 비밀번호를 제출하면 모델을 검사하고 로그인과 비밀번호가 맞으면 스크립트는 완료된 로그인 프로세스에 대한 메시지를 표시합니다. 그러나 내가 echo $message;
보기에 넣고 로그인 페이지에있는 경우, kohana는 오류 - 정의되지 않은 변수 $ 메시지를 표시합니다. 그러나 내가 페이지에서 변수가 정의 된 곳에서 작동 할 때. 이 아이디어를 실현하는 법.로그인 스크립트에 대한 아이디어
EDIT!
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
'action','model','view'를 보여줄 수 있습니까? – vietean
제 편집을 확인하십시오. – reGative