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?
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");
?>