I have a form, and the submit button checks if it is true or false.
If true, redirect to another page.
If it is false, stay on the same page and print an error message.
The error message is printed using the flash messenger. But in some cases, it does not print in the first attempt, when submit is false, it always prints in the second click.
Did I do something wrong? And is there also a way to make a difference in the name of a flash messenger? Because on other pages that have a flash messenger, print an error message when you refresh the page.
Here is the code:
if(isset($_POST['submit'])) {
if(true) {
} else {
$this->_helper->flashMessenger->addMessage(" This email is already taken");
$this->view->messages = $this->_helper->flashMessenger->getMessages();
}
}
HTML:
<center>
<div style="color:red">
<?php if (count($this->messages)) : ?>
<?php foreach ($this->messages as $message) : ?>
<div id="field_name">
<strong style="text-transform:capitalize;">Email </strong>
- <?php echo $this->escape($message); ?>
</div>
<?php endforeach; ?>
<?php endif; ?>
</div>
</center>
source
share