• Create Account

### #ActualServant of the Lord

Posted 21 August 2012 - 10:48 AM

Hello - I'm working on some features for my website, and I have a few questions about redirection.

Whenever the user visits a certain page, I want the following things to happen:
A) A (hidden) counter is incremented, so I know how many times that specific page was visited.
B) The user gets redirected to a new page.

Since the page wasn't "moved", status codes 301 and 302 don't really make sense.
Am I understanding that 303 is the best code to send to the user's web browser?

Something like:
header("HTTP/1.1 303 See Other");


The redirection destination page may be on a different website, depending on which page is visited.

I'm not supposed to put any PHP or HTML code before the header() stuff... but can I add PHP code after the header() calls, to increment the counter?
[Edit:] Ah, I'm not supposed to put any PHP code that outputs text (or other content), right? Non-outputting PHP is fine?

Also, should I save user visits to the MySQL database, or to just a text file? Either would work, but which would you personally use?

### #1Servant of the Lord

Posted 21 August 2012 - 10:42 AM

Hello - I'm working on some features for my website, and I have a few questions about redirection.

Whenever the user visits a certain page, I want the following things to happen:
A) A (hidden) counter is incremented, so I know how many times that specific page was visited.
B) The user gets redirected to a new page.

Since the page wasn't "moved", status codes 301 and 302 don't really make sense.
Am I understanding that 303 is the best code to send to the user's web browser?

Something like:
header("HTTP/1.1 303 See Other");