how to show in a div another page according to the link of the page?

-1

I'm making a web where I made a form where when I send it I create a new php file, I have a template where in a div I show the content of the new file created, I'm doing it with an iframe it loads me well and everything, but the problem that I have is that I want that template to load in the iframe the content of the file that I want, I explain, I want the link to open the page to upload the iframe that I want, if I put www.mipagina.com/iframe?iframe1 I see the iframe 1 if I put www.mipagina.com/iframe?iframe2 I load the iframe 2 so, so I want that from a single page I can load all the iframes but with a link that opens the iframe that I want, that I do not have to enter first to the page and I choose the iframe . or if you can give me some other suggestion to achieve this, it's not necessarily with iframes. Thanks.

    
asked by Stivents 30.10.2016 в 15:10
source

1 answer

0

What is intended is to capture the value that comes by request GET (? iframe = iframe1) to then validate and know what content will be displayed.

To obtain the value of these variables there is $ _GET ['parameter'] , in your example to get the value of iframe www.mipagina.com/iframe?iframe1 would be $_GET['iframe'] where iframe will be the parámetro sent by URL

Complete Example

<?php 
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
    if(isset($_GET['iframe'])){
      $parametro= htmlspecialchars($_GET['iframe']);
       switch ($parametro) {
         case 'iframe1':
           echo "iframe1" ;
           break;
        case 'iframe2':
           echo "iframe2" ;
           break;
        default:
           break;
       }
     }
   } 
 ?>

About SRC of iframe received per parameter would be already without a switch

<?php 
  if ($_SERVER['REQUEST_METHOD'] === 'GET') {
    if(isset($_GET['iframe'])){
     $parametro= htmlspecialchars($_GET['iframe']);
       echo "<iframe src='$parametro'></iframe>"
   }
}
    
answered by 30.10.2016 / 16:36
source