Log in

View Full Version : PHP linkin (GET method)



fndanielnl
06-01-2007, 04:03 PM
What i want is that links to an other php page not are of index.php to info.php but of index.php to index.php?page=info.php

The fellowing script is doing that: (index2.php is the main page)

<?php
if($_GET['page']=='info')
{
include('info.php');
}
else
{
include('index2.php');
}
?>

But when i add a second page on the same way as info.php he does not only display the second page but also index2.php.

How can i fix this. I have allready tried a lot of things but i am not very good whit php scripts!

thetestingsite
06-01-2007, 04:06 PM
For every other condition (other than the first if and the last "else" statement), you need to have "elseif".



<?php
if($_GET['page']=='info')
{
include('info.php');
}

elseif ($_GET['page'] == 'other') {
include('other.php');
}

else
{
include('index2.php');
}
?>


Hope this helps.

fndanielnl
06-01-2007, 04:40 PM
Yes it is working perfect

Thank you very much!!:)