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?
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.
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!
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.