I use template template XTemplate (2007).
Old but doing his work conscientiously)
The problem is that after parsing it produces the finished result and displays it in the browser. I want to get around the problem of re-sending a message when the page is updated. Redirect can not be screwed.
Essence: after entering the login / password in case of an error, the same page is opened with an error message. When you click on F5 or refresh the page, the form will be resubmitted.
Controller:
$xtpl = new XTemplate('main.html', ROOT . '/views/'); $xtpl->array_loop( 'page.authorization.i', 'error', $errors ); $xtpl->assign('p', $p); $xtpl->parse('page.authorization'); $xtpl->parse('page'); $xtpl->out('page'); html:
<!-- BEGIN: page --> <!DOCTYPE html> <html> <head> <title>Авторизация пользователя</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> </head> <body> <!-- BEGIN: authorization --> <h1>Вход</h1> <!-- BEGIN: i --> <p>{error}</p> <!-- END: i --> <form action="" method="post"> <div> <label for="login">Логин:</label> <input type="text" name="login" id="login" value="{p.login}"> </div> <div> <label for="password">Пароль:</label> <input type="password" name="password" id="password" value="{p.password}"> </div> <div> <input type="submit" name="submit" value="Войти"> </div> </form> <!-- END: authorization --> </body> </html> <!-- END: page --> Out function:
public function out ($bname) { $out = $this->text($bname); echo $out; } Maybe there is a header parameter to cram the result of the template into it and open the page with this data?