Redirect to another page based on user actions

Discussion in 'PHP' started by Twayne, Jun 22, 2008.

  1. #1
    Hi,

    How would I go about "forcing" a user from one page to another?

    I have a very simple random question/answer entrance requirement for an e-mail form. After 3 page views most people are going to have successfully submitted their e-mail (enter/validate as human, enter message, send the message). If someone or something decides to start banging on any of the pages and increses the views count too far I want to kick them out to an explanatory page (just in case it's really a little old lady or whatever).
    Counting views and getting the error state is easy. But how do I "force" the visitor off to that "explanatory" page?

    Or is there a better way to treat this situation?
    Or is there any way to easily just disconnect them from my site somehow?
    I thought about using sleep or usleep but ... not sure how reliable that might be and it could really PO some poor little old lady.
    This is for a non-profit agency's web site so I need to be "gentle" if I can<g>.
     
    Twayne, Jun 22, 2008 IP
  2. King Goilio

    King Goilio Member

    Messages:
    200
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    33
    #2
    you could change the header to send them to another page or just make it send a 404 error
     
    King Goilio, Jun 22, 2008 IP
  3. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #3
    die(header('Location: TheUrl'));
     
    Danltn, Jun 23, 2008 IP
  4. Twayne

    Twayne Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Yes: That's the solution I was looking for! Thanks.
     
    Twayne, Jun 23, 2008 IP