0

I have added This Code in My Domain2 where i want this code to be executed Running If it From domain 1

 <?php if(isset($_GET['id2'])) { $id2=$_GET['id2']; echo "www.xxxxxxxxxx"" ></iframe>";}
                                                    else
{
echo "Not Found";

}

I try this code but not working If anyone direct accesses this https://Domain2.com/xxxxxxxx/?id=xxxx Hidden part of is showing How to make hidden if it not Redirected By https://Domain1.com/away.php

2 Answers2

1

You can use $_SERVER['HTTP_REFERER'] to make sure that the refering page (previous page) was the one that you expect:

<?php 
// if the request comes from a file that contains the string "conforming.php" then render the page
    if(stristr($_SERVER['HTTP_REFERER'], "conforming.php")) {
         //serve page if came from conforming.php
     }
// if the referring page is not conforming.php, then redirect the user to the conforming version
    else  {
        header("Location: conforming.php");
    }
?>

additional information: https://www.w3.org/TR/WCAG20-TECHS/SVR3.html

EDIT** I customized the code below according to your additional requirements:

<?php 

if (stristr($_SERVER['HTTP_REFERER'], "https://Domain1.com/away.php"))
{
    if (isset($_GET['id2']))
    {
        $id2 = $_GET['id2'];
        echo "<iframe frameborder=\"0\" scrolling=\"no\" width=\"560\" height=\"320\" src=\"https://www.xxxxxxxxxx.com/files.php?v=$id2\" allowfullscreen=\"true\" webkitallowfullscreen=\"true\" mozallowfullscreen=\"true\" ></iframe>";
    } else{
        echo "id is empty";
    }
    
}
else
{
    //invalid referer! go back to domain1 to make it valid!
    header("Location: https://Domain2.com/xxxxxxxx/");
}

?>
cabrillosa
  • 155
  • 8
0

What you are looking for is exit;

<?php 

if(isset($_GET['id'])) 
{ 
  $id1=$_GET['id']; echo "xxxxxxxxxx=$id1";}
else {
  echo "stop";
  exit;
}

?>

Exit will terminate the execution of the current script. This will then continue with the execution processes, which will call your next function.

More reading here: https://www.php.net/manual/en/function.exit.php

Sweet Chilly Philly
  • 3,014
  • 2
  • 27
  • 37