This is what runs after submitting a form:
else
{
echo '<br/> Tu chisme se agregó con éxito.';
echo '<script type="text/javascript">window.location.reload(true);</script>';
}
Basically after the users submits the form it does a couple of things and finally displays a text saying that the post has been submitted successfully and then a second echo tries to reload the page. However I wasn’t able to make it work. It displays the text but it doesn’t reload the page. What’s the problem with the code? Please ask for any info. Thanks
The right thing to do after a POST is a ‘Redirect After Post’, that means sending an HTTP header with a 303 code (not a simple 302 code, most browser will prevent you from reposting with the back button if you use the 303 code, it’s done for that purpose).
You should’nt have send anything before sending this HTTP header code (try using
ob_start/ob_flushfunctions to control that).So, well, in fact the HTTP protocol contains everything you need to control behavior after POST requests, it’s really better to avoid use of JavaScript for that.