Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dynamic url generation

Status
Not open for further replies.

monkle

Programmer
Feb 11, 2004
132
US
I have just added a mini cart view to our website, and I have run into a problem. There is a "more info"/"less info" link in it. For compatibility reasons, I did it purely in php.

The problem is this: some of the pages on the site use $_GET and/or $_POST data. I'm trying to find a way to be able to pass the $_GET data along, and am considering simply hiding the minicart view on pages with $_POST data.

I have already gotten to the point of re-creating the exact web address for the page the user is on, but I haven't gotten through obtaining the $_GET data. I think I could re-create it, but I really don't want to do it with a static solution, such as checking for exact variables. I think the reasons for not wanting that are fairly obvious.

So, I guess the questions I have are as follows:
Am I headed in the right direction with this?

If you think I'm just way off in left field with my concept design, what angle should I aproach the issue from?

If I'm headed in the right direction with finding a way to return the full, exact url, how can I do this?

If I'm headed in the right direction with re-creating the $_GET and/or $_POST data, how do I retreive the variable names (eg. if the url ends in ?testval=1 how do I get the name "testval")

I've spent several days now looking for hints in the php documentation, searching the internet, searching this forum (faq/threads), and experimenting. If you can address any of the questions I have or at least point me in the right direction, I would appreciate it greatly.
 
Are you talking about going back through 400+ files and replacing all variable passing functionality with session data? I have thought of it. I have not considered it.
 
Could you explain a little more about what you are doing, would have thught you would have to alter all 400+ files any way (I'm assuming 400 .php code files).
I'm not clear on when you say for example
I have already gotten to the point of re-creating the exact web address for the page the user is on,
Where are you re-creating the page ?
 
I have been working for quite some time on developing an online order entry system. You can see it at The code for getting the web address in the script is as follows:

Code:
$urlcurrent = $_SERVER['SERVER_NAME'];
$urlcurrent .= $_SERVER['PHP_SELF'];

The minicart itself is in an include, that is included in the startpage include.

I am assuming that by saying "use session variables", you're talking about replacing the $_GET and $_POST data that I am having a hard time passing to the page when I change the minicart view from "less info" to "more info", or vice versa.

If you mean putting the state of the minicart view into the session variable, then yes, that is how that part of it is handled.
 
I have solved the problem. I now re-create the full uri for the page with the following code:

Code:
$urlcurrent = $_SERVER['SERVER_NAME'];
$urlcurrent .= $_SERVER['PHP_SELF'];
$get = $_GET;
$getkeys = array_keys($get);
$getvalues = array_values($get);
if (is_array($getkeys))
{
  $i = 0;
  $ubound = count($getkeys);
  while ($i <= $ubound)
  {
    $key = $getkeys[$i];
    $value = $getvalues[$i];
    $geturldata .= "&$key=$value";
    $geturldata .= $i < $ubound ? '&' : '';
    $i++;
  }
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top