#1
  1. Learning all I can
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2007
    Location
    Pleasanton, California, USA
    Posts
    287
    Rep Power
    9

    Header("Location: $variableHere")


    I searched online and can find no specific info on my issue.
    The start session script evaluated at the top of my website files includes these lines:
    PHP Code:
    $redirect 'http://whatever.com/login.php'// redirect to login page if rejected
        
    // if session variable is not set, redirect to login page
    if (!isset($_SESSION['authenticated']) || $_SESSION['authenticated'] != 'HighTimes') {
      
    header("Location: $redirect");
      exit;

    In that next-to-last line, it seems that the variable is naked between those double quotation marks,
    and would therefore not be evaluated. Can you tell me if that line should instead read:
    header("Location: {$redirect}");
    with curly braces around the $redirect variable name?

    Thank you,
    Curtis
    Curtis
    - living a newbie's dream
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    1
    Rep Power
    0

    *facepalm*


    It's not working because php takes "$redirect" as a string.
    Try replacing your header function with this one;

    PHP Code:
    header('Location: '.$redirect); 
    Last edited by phphelix; November 24th, 2012 at 02:30 AM. Reason: fixing up some errors
  4. #3
  5. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    @ cstallins:

    Replace the header() with an echo. What does it say?



    @ phphelix:

    You do know the purpose of double quoted strings, right? If you have knowledge about a special configuration value or bug that will prevent variables inside double quoted strings from being evaluated, please share it with us.
  6. #4
  7. Learning all I can
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2007
    Location
    Pleasanton, California, USA
    Posts
    287
    Rep Power
    9
    Thank you both for your help with this. I'll dial it in.
    Curtis
    Curtis
    - living a newbie's dream

IMN logo majestic logo threadwatch logo seochat tools logo