SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Zealot Hulkur's Avatar
    Join Date
    Oct 2001
    Location
    Estonia
    Posts
    141
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    require with variables and cookies

    code: (in edit.php)

    require("http://mydomain/list.php?reg=1&id=0");


    Page loads, but cookies have no effect on page.

    I use cookies to track users and depending on their level
    i want to show different amount of information.
    I'm logged in as Admin,but after edit i have no access anymore.

    Any ideas?
    (2B) or (not 2B) = FF

  2. #2
    SitePoint Zealot Hulkur's Avatar
    Join Date
    Oct 2001
    Location
    Estonia
    Posts
    141
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Solved it differently
    instead of 'require' i use now

    header("Location: list.php?reg=1&id=0")

    and it works fine.

    Just in case someone stumbles on same problem.
    (2B) or (not 2B) = FF

  3. #3
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you can't use that if theres anything outputted to the browser before the header() call.

    also that will just redirect the visitor to that page, not include the contents of the required file into the current script.
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*

  4. #4
    SitePoint Zealot Hulkur's Avatar
    Join Date
    Oct 2001
    Location
    Estonia
    Posts
    141
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    this is in submit.php which doesn't utput anything so no problem there.

    redirect was my intention, i want to show list again after user has updated row data.

    list -> edit -> submit -> back to list
    (2B) or (not 2B) = FF

  5. #5
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    all require() does is subsititues itselft for the code in the required file, so of couse you can't redirect with it.

    is all you were doing is have a file with
    PHP Code:
    <?php
    require("http://mydomain/list.php?reg=1&id=0"); 
    ?>
    in it?
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*

  6. #6
    SitePoint Zealot Hulkur's Avatar
    Join Date
    Oct 2001
    Location
    Estonia
    Posts
    141
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    no

    in short...
    Code:
    if (id>0) 
       // edit existing
    else
      // insert new
    // if error
    echo "Error"
    // else back to list
    require(...)
    basically i was using wrong approach as i wanted redirection,
    i just didn't know that it can be done with headers.

    But question is still this: why have cookies no effect when i use require? If it substitutes it's code then cookies must be in effect already, but in my case they are not.

    It works this way - require("list.php"), but not when i do require("http://mydomain/list.php?reg=1")
    (2B) or (not 2B) = FF

  7. #7
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by Hulkur
    It works this way - require("list.php"), but not when i do require("http://mydomain/list.php?reg=1")
    That's because require for all intents and purpose is copying and pasting the whole scripts code where require() is being called, so a query string has not effect.
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •