Jump to content

Another Question About urls and how to work with them.


takn25

Recommended Posts

Hi again,

  okay going to be a bit difficult to explain clearly but i will try. For instance i have a script on my categories.php ready to run when called from index.php I land on this page no 1 /categories.php?name=$pagename  from there the user has an option to go this page 2,

 

/categories.php?name=$pagename&id=$myid      <---  ok my question.. is it best to carry on scripting on categories.php for both pages (urls) or is it best to make another page example categories2.php for page number 2. Currently all my code is on categories.php and it is performing as desired. Still i want to know which is better and how do you guys work, if you have a similar case any suggestions and guidance would be appreciated thanks all.

My gut tells me that you should create another PHP file to process the 2nd page / step. This feeling comes from the idea of script responsibility. Similar to if you give a class, method or even a standalone function too much responsibility it becomes difficult to maintain. The same might be said for reusing the categories.php script.

 

I also envision an efficiency issues with reusing categories.php- the logic you have when the user lands at page 1, will be re-executed for page 2. Re-executing this logic might be meaningless and a waste of resources.

 

Lastly if you need to make a change to page 1's logic (say you discover a bug or need to add a new feature) you're most likely going to break page 2 if you re-use categories.php.

 

If your concern is propagating the $pagename variable to the various pages Id suggest using sessions or appending the parameter onto the URL for the next page.

 

- Nick

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.