Base page and sub pages

There’s a website I’m trying to recreate as they have a distributor in a new country and I’m trying to get their website done (This is stated in case anyone thinks I’m plagiarizing their content).

The website I’m trying to copy is https://www.powerair.eu

On their products page they have a submenu that allows one to navigate pages but from what I can tell, the submenus are linked to pages like https://www.powerair.eu/products.php?sl=en&parent=car

I use a fairly standard form of html where I would create a separate page for each product and the whole “&parent=car” part is confusing because when I check the source code for it, it looks like the same “products.php” page but the content is different.

Can someone please explain to me how this part works (where it displays different content but still has the same base page) I need to get this done quickly so any help would be appreciated.

Thanks in advance.

Answer

It uses the $_GET global variable. It may be using some underlying logic that relies on the value of that variable. For an instance if a page url looks like

https://example.com/sample.php?product=shoes

A developer may use the $_GET['product'] variable to access its value.

For an example it can be:

<body>
  <?php
     $dynamic_value = isset($_GET['product']) ? $_GET['product'] : 'Default Value';
  ?>

  <h1><?php echo $dynamic_value ?></h1>

</body> 

By utilizing the logic above, one can use the $_GET["product"] variable to fetch data on database etc.

however there are safety precautions that must be tackled such as sanitizing inputs and more. You can read more about using the $_GET variable here

Leave a Reply

Your email address will not be published. Required fields are marked *