Jump to content

multiple variables in php url?


philrocksgca

Recommended Posts

i really need some help bad lol

 

so im a noob with php and i need some advice. i call content currently with "index.php?page=example"

 

with this

<?php
if (isset($_GET['page'])&& $_GET['page'] != "") {
$page = $_GET['page'];
if (file_exists('pages/'.$page.'.php')) {
@include ('pages/'.$page.'.php');
    } elseif (!file_exists('pages/'.$page.'.php')) {
    echo 'Page you are requesting doesn´t exist';
}

} else {

@include ('pages/home.php');

}

?>

 

but on a page im doing inside, i need to use a variable too

 

like: "index.php?page=example&id=1"

 

can someone help modify my script so i can get this to work :)

Link to comment
https://forums.phpfreaks.com/topic/130510-multiple-variables-in-php-url/
Share on other sites

btw

 

  if (file_exists('pages/'.$page.'.php')) {

  @include ('pages/'.$page.'.php');

    } elseif (!file_exists('pages/'.$page.'.php'))

 

if  (file_exists('pages/'.$page.'.php')) then for sure anything than that will be  !file_exists('pages/'.$page.'.php').

 

All I'm saying is you don't need to say it again in elseif.  just use else.

 

 

  if (file_exists('pages/'.$page.'.php')) {
   @include ('pages/'.$page.'.php');
    } else

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.