1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Dynamic URL?

Discussion in 'PHP' started by NITRO23456, May 1, 2009.

  1. #1
    Hi

    I am trying to make an URL where the entries by the current user is displayed on a database driven website usign the search function.

    For example:

    http://www.mysite.com/myproject_list.php?a...&SearchFor=JOHNSMITH&SearchOption=Equals&SearchField=RECEIVED+BY

    Works statically so everyone can see that users entries, but if I try to make it dynamic (ie for the current user.... whoever is logged in) it doesnt work:

    http://www.mysite.com/myproject_list.php?a...&SearchFor=$_SESSION["UserID"]&SearchOption=Equals&SearchField=RECEIVED+BY

    any ideas?
     
    NITRO23456, May 1, 2009 IP
  2. yz4now

    yz4now Peon

    Messages:
    26
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hey, $_SESSION["UserID"] is PHP, thus it will not work in the address bar. It must be executed by the server before the page is loaded. So you need to send the user to that URL before the server loads. For example say the user just logged in you can do something like this:

    $url = user.php?user=$_SESSION["USERID"];
    header("Location:$url");

    This will send the users browser to the URL.
    If you are doing something like search like I think that you are doing above. You can use the method="get" for the html input.

    Hope that helps.
     
    yz4now, May 1, 2009 IP
  3. NITRO23456

    NITRO23456 Well-Known Member

    Messages:
    516
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    110
    #3
    Thanks!

    What I am trying to do is redirect my users after they have added a record to the database, to the list page (that currently holds ALL records) but only show their records added from that current day, so they only see their records added today rather than everyones added over time.

    I was trying to do this using the 'search' function of my project (which works statically for one user on one date) but make it dynamic so that this occurs for whoever is logged in on whatever day.

    Whilst your answer makes sense to me I am not sure how to implement this, I only have basic PHP knowledge. I thik I would need to use the search function to filter everyone else out. Any more help would be great!
     
    NITRO23456, May 2, 2009 IP
  4. yz4now

    yz4now Peon

    Messages:
    26
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    So after you add a record where are the users taken to?
    Im not fully understanding what you got setup.
    I would say after you query the database to insert the new data use this code after:
    $url = user.php?user=$_SESSION["USERID"];
    header("Location:$url");
    To redirect them to the correct page.

    Hope that helps.
     
    yz4now, May 2, 2009 IP