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 --> 

XTemplate itself

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?

  • one
    I didn’t quite understand what the problem was, and what’s the reason for that? I understand the snag is that you submit the form with a post-request. Get an answer. Press f5, and the browser tells you like "the page is out of date, send the data again?" . This is the usual behavior for a post request. Therefore, explain what the template system is all about. - teran
  • to get rid of this, you need to redirect to a get-method after unsuccessful authorization. But here you have to save login errors in the session and all that. So usually no one does. Or else authorization is generally possible through ajax-do. - teran
  • I explain: I send request from the POST page. In the controller, I process it and call the template structure for output of the processed result, which displays the result via echo. The problem is that if you click on F5 (well, refresh the page), the browser says: "To display this page, Firefox has to send information that will repeat any previously performed action (for example, a search request or online purchase)." - azhirov1991
  • And so, it would be possible to make a redirect without re-sending ... - azhirov1991

0