Let's imagine html login code in index.php
<form action="index.php" method="POST">
<input name="Login">
<input name="Password">
<input type="submit" value="Check">
</form>
and php code in index.php file before html
<?php
if(isset($_POST['Login"]))
{
//check for auth 1*
}
?>
1* if check failed,in that page we need to show something like "You entered wrong login or password..." and also display fields to fill.But now user can click F5 as many time as he wants and get same message shown,as soon as, all parameters are sent again in Post.What I need is: show error message,but when user click refresh button,don't post parameters again. So how can I get around this issue? As I understand PRG pattern wouldn't work here.Is it a good way to set a cookie,redirect to same page,show message if cookies exist and remove cookie?
if(isset($_COOKIE['LoginError']))
{
echo 'You entered invalid login or password';
setcookie('LoginError','',time()-3600,'/');
}
else if(isset($_POST['Login']))
{
//check here for invalid values
//if there is error do next
setcookie('LoginError','1',time()+84600,'/');
header("location: index.php");
}
but in my opinion,it's not good way