Reputation: 1074
i was wandering how i could hide content of a page based on the page you are located , i did this with the code from below , however i was wondering how i could hide a page that is generated dynamically for example index.php*?id=......*.
Is there a php function that i could use that would say disregard all that is after .php so don't take into consideration ?id=.. .
if($_SERVER['PHP_SELF'] != "/3uboats/index.php"){
CONTENT TO HIDE
}
If i was not clear plz ask for clarification , thanks all in advance
i want to hide content for this page stampa_fattura_partenza.php?id_prenotazione_partenze=1 the 1 is generated by php , its dynamic
Upvotes: 0
Views: 685
Reputation: 2577
What you can do is get the value of your id using $_REQUEST["id_prenotazione_partenze"] or $_GET["id_prenotazione_partenze"] and use that in your php IF.
if($_REQUEST["id_prenotazione_partenze"]==1){
// HIDE
}
This hides content when your page id = 1 for example.
Upvotes: 1
Reputation: 1533
You can check whether $_REQUEST[ "id_prenotazione_partenze" ]
is set, like:
if( isset( $_REQUEST[ "id_prenotazione_partenze" ] ) ){
//hide content
}
Then if any value is passed with $_REQUEST[ "id_prenotazione_partenze" ]
it will evaluate the if
statement.
Upvotes: 1
Reputation: 47945
You should better not use $_SERVER['PHP_SELF']
that is insecure. You could check if a variable is set by this code:
if(isset($_GET['id_prenotazione_partenze']) &&
$_GET['id_prenotazione_partenze'] != 1) {
...
}
This should work for your example.
Upvotes: 1