Hello,
I'm setting a PHP session variable with a success message for a HTML form that I'm submitting. If there are no form errors, I redirect to the same page (using header()) and display the message from the session variable. Everything is fine until here, but if I access that page again after submission, the message is still there. Is it possible to make it appear only when I redirect after a successful submit?
My code for form.php looks like this:
if (isset($_POST['submit'])) {
// some form processing here
if (count($errors) == 0) {
// some data saving here
$_SESSION['status'] = 'Thank you for submitting the form';
header('Location: /form.php');
}
And now my template file:
{if isset($smarty.session.status)}
<p><strong>{$smarty.session.status)</strong></p>
{/if}
<!-- form html code goes here -->
Thank you.