Eren
Eren

Reputation: 183

PHP - Detect URL (test.html?variable=1)

I want to make a system that detects URL and changes one of the iframes URL.

I don't know PHP so much but I want to make something like this.

Note that I am not going to use 2 links. I am going to use multiple links. So If-Else would'nt works.

Upvotes: 0

Views: 550

Answers (3)

Eren
Eren

Reputation: 183

I made a play.php and write this simple code

<?php
echo '<iframe style="display: block; position: absolute; top: 0px; left: 0px;" width=100% height=100% src="' .htmlspecialchars($_GET["server"]). '" frameBorder="0">
        </iframe>'
?>

Whenever you type play.php?server=//serverlink.com it creates a iframe with that URL.

Upvotes: 0

Pastor Dur&#225;n A.
Pastor Dur&#225;n A.

Reputation: 374

A example from basic php for get the parameters of any url.

$servers = array
  (
  array(1,"serverxxx"),
  array(2,"serveryyy"),
  array(3,"serverzzz")
  );

 if(isset($_GET)){
     $params = array_keys($_GET);
     for( $i=0; $i<count( $params ); $i++ )
         if(isset( $_GET[$params[$i]]) ){
             for($j=o;$i<count($servers);$j++){
               $id =$_GET[$params[$i]];
               if($id==$server[$j]) {
                 $src = $server[$j][1]];
                 break;
               }       
             }
         }
 } ;

Upvotes: 4

Callan Heard
Callan Heard

Reputation: 727

Use $_SERVER['REQUEST_URI'] to retrieve the URI after the domain name

Upvotes: 0

Related Questions