#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    3
    Rep Power
    0

    Qualified redirection?


    Please excuse the simplicity and likely stupidity of this question, but I can't figure it out anywhere, so I'll ask.

    What I want to do is make a php script that will automatically redirect the user to a different page if certain qualifications are met. The problem is, I can't find a command to automatically initiate a link besides when the page initiates. How would I do that?
  2. #2
  3. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,072
    Rep Power
    9398
    "Initiate a link"?

    A redirection is as simple as
    PHP Code:
    header("Location: /where/you/want/them/to/go");
    exit; 
    but you must not have outputted anything by that point.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    22
    Rep Power
    0
    To expand on requnix, you can have PHP code to do the evaluation before header(); Just not any code that generates HTML output.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2004
    Posts
    2,990
    Rep Power
    375
    Originally Posted by acray
    To expand on requnix, you can have PHP code to do the evaluation before header(); Just not any code that generates HTML output.
    not even a "space"
  8. #5
  9. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,908
    Rep Power
    6351
    Not even necessarily any CODE before the header(). If you have an include file that ends in "?> " then you'll get those 2 spaces in your output and header() won't work.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.

IMN logo majestic logo threadwatch logo seochat tools logo