-1

I want to get information from this link

index.php?site=server?id=1

when I try to reach id=1 my system crashed.

<?php
    $site="";
    $site=$_GET['site'];
    if(!isset($site)) $site="news";
    $invalide = array('\\','/','/\/',':','.');
    $site = str_replace($invalide,' ',$site);
    if(!file_exists($site.".php")) $site = "error";
    include($site.".php");
?>

Can someone help me upgrade this system to get data second segment?

ptR
  • 1
  • 1
  • Ok, hold on a second, at what line exactly did you try to reach id? because I can't seem to find it. – Spoody Oct 07 '17 at 19:17

1 Answers1

1

index.php?site=server?id=1 this URL is incorrect to begin with, here's the right one index.php?site=server&id=1.

? is used to separate the base URL from the query parameters, so you should have ONE ? in a link; to provide multiple query parameters, you should use & between them. Here's an example.

page.php?key=value

page.php?key1=value1&key2=value2&key3=value3

<?php
  $invalide = array('\\','/','/\/',':','.');
  $site="news";
  if(isset($_GET["site"])) $site = $_GET["site"];
  if(isset($_GET["id"])) $id = $_GET["id"];
  $site = str_replace($invalide,' ',$site);
  if(!file_exists($site.".php")) $site = "error";
  include($site.".php");
?>
Community
  • 1
  • 1
Prav
  • 2,785
  • 1
  • 21
  • 30