[php?] How does Vbulletin do it?

Joined
Apr 29, 2005
Messages
6,400
Reaction score
131
On my blog when ever you post a reply and then press refresh an alert comes up warning that if you refresh the page all form data will be resubmitted. I've found a workaround for it so that's not really a problem.

But if you submit a reply on vbulletin and then refresh no alert comes up, nor does the form get resubmitted. Which is exactly what I need for my blog, so I was wondering if anyone had an idea on how they did it?
 
Their quickreply uses AJAX. What works also quite well is using a header redirect to the page where the submit came from:

PHP:
header("Location: " . $_SERVER['HTTP_REFERER']);

Add this after you've processed the POST data (ie, add a reply to the DB for example). The user will get redirected without knowing it and if he refreshes he will refresh the new page you redirected him to, which doesn't contain form data.

As for AJAX, a very good and easy to use toolkit is SAJAX, check out their examples :smile:
 
Make it go to a different page, for example:

index.php?random=3845937

Not sure, but it has something to do with the redirecting. You need to clear the browsers cache of the form, works by going to one temp page, then back to the original too I guess.
 
Their quickreply uses AJAX. What works also quite well is using a header redirect to the page where the submit came from:

PHP:
header("Location: " . $_SERVER['HTTP_REFERER']);
Add this after you've processed the POST data (ie, add a reply to the DB for example). The user will get redirected without knowing it and if he refreshes he will refresh the new page you redirected him to, which doesn't contain form data.

Yeah, I already wondered why it never happened to my apps :P.

What basically happens with processing forms, is that it refreshes the page (or go to the location you specified), processes information (PHP) then gets to another page using headers. Atleast thats what I used to do :).
 
Their quickreply uses AJAX. What works also quite well is using a header redirect to the page where the submit came from:

PHP:
header("Location: " . $_SERVER['HTTP_REFERER']);
Add this after you've processed the POST data (ie, add a reply to the DB for example). The user will get redirected without knowing it and if he refreshes he will refresh the new page you redirected him to, which doesn't contain form data.

As for AJAX, a very good and easy to use toolkit is SAJAX, check out their examples :smile:

Oh wow, thanks a bunch ff, that worked like a charm. Now I can remove my gay anti-flood protection.
 
Back