php in php display corresponding pages

  • sai
  • Born
  • Born
  • sai
  • Posts: 2

Post 3+ Months Ago

Hai

I an new to PHP and need some help.

what i am trying to do is

A php page such that it shuld have the some links on the top

world | windows | linux | DOS|

and every time we click on any of these links the corresponding pages should be displayed......

tat is the a page snippet corresponding the windows url shuld be displayed if i click dos ..........


I am calling my tech.php(which contains the above link) into the index.php

and my tech.php has the following code



tech.php
------------------
Code: [ Select ]
<!-- Begin Left Menu -->
<?php require("http://host/menus/top.php"); ?>
<!-- End Left Menu -->

<!-- Begin PhP content -->
<div id="tech">
<?php
switch($HTTP_GET_VARS['page'])

{ /* Script courtesy of EvilWalrus.com */
case '0':
include ' http://host/content/home.php ';
break;
case '1':/* Alias for the actual page for security purposes */
include ' http://host/content/win.php ';
break;
case '2':
include ' http://host/content/linux.php ';
break;
case '3':
include ' http://host/content/dos.php ';
break;

default:
include ' http://host/content/home.php ';
break;
}
?>
  1. <!-- Begin Left Menu -->
  2. <?php require("http://host/menus/top.php"); ?>
  3. <!-- End Left Menu -->
  4. <!-- Begin PhP content -->
  5. <div id="tech">
  6. <?php
  7. switch($HTTP_GET_VARS['page'])
  8. { /* Script courtesy of EvilWalrus.com */
  9. case '0':
  10. include ' http://host/content/home.php ';
  11. break;
  12. case '1':/* Alias for the actual page for security purposes */
  13. include ' http://host/content/win.php ';
  14. break;
  15. case '2':
  16. include ' http://host/content/linux.php ';
  17. break;
  18. case '3':
  19. include ' http://host/content/dos.php ';
  20. break;
  21. default:
  22. include ' http://host/content/home.php ';
  23. break;
  24. }
  25. ?>


the top.php
---------------
Code: [ Select ]
<table width=850 cellpadding="3">
<tr align=center>
<td align="center" width=132><a href="http://host/content/tech.php?page=0">Tech Home</a></td>

<td align="center" width=5> | </td>

<td align="center" width=132><a href="http://host/content/tech.php?page=1">Windows</a></td>

<td align="center" width=5> | </td>

<td align="center" width=132><a href="http://host/content/tech.php?page=2" >Linux</a></td>

<td align="center" width=5> | </td>

<td align="center" width=132><a href="http://host/content/tech.php?page=3"> DOS</a></td>

<td align="center" width=5> | </td>

<td align="center" width=302><a href="http://host/content/tech.php?page=4" > Free Downloadable Programs</a></td>
</tr>


</table>
  1. <table width=850 cellpadding="3">
  2. <tr align=center>
  3. <td align="center" width=132><a href="http://host/content/tech.php?page=0">Tech Home</a></td>
  4. <td align="center" width=5> | </td>
  5. <td align="center" width=132><a href="http://host/content/tech.php?page=1">Windows</a></td>
  6. <td align="center" width=5> | </td>
  7. <td align="center" width=132><a href="http://host/content/tech.php?page=2" >Linux</a></td>
  8. <td align="center" width=5> | </td>
  9. <td align="center" width=132><a href="http://host/content/tech.php?page=3"> DOS</a></td>
  10. <td align="center" width=5> | </td>
  11. <td align="center" width=302><a href="http://host/content/tech.php?page=4" > Free Downloadable Programs</a></td>
  12. </tr>
  13. </table>


now the problem is

it is not displaying home.php contents even when i have given the full path .

and when i click on the links then it take me to the new page with only the top.php and the page which is clicked .

I want that it shuld remain in the index.php and only the tech.php shuld change according to the contents .........

any suggestions will be reallly great!!!!!!

thanks

urs
sai
  • _Leo_
  • Proficient
  • Proficient
  • User avatar
  • Posts: 279
  • Loc: Buenos Aires, Argentina

Post 3+ Months Ago

Change all case from:

case '2'

to

case 2

I mean, remove the single quote, PHP thinks you are talking about strings, and '0' is not an empty one. You may change case '0' to case ''
That will match the case. I think it's better using numbers anyway. You may avoid the case '0':, use defaut: and then pass an empty page to get the home. That's another solution:

Code: [ Select ]
switch($HTTP_GET_VARS['page']) {

case 0:
  include('home.php');
  break;

case 1:
  include('win.php');
  break;

case 2:
  include('linux.php');
  break;

case 3:
  include('dos.php');
  break;

default:
  include('home.php');
  break;
}
?>
  1. switch($HTTP_GET_VARS['page']) {
  2. case 0:
  3.   include('home.php');
  4.   break;
  5. case 1:
  6.   include('win.php');
  7.   break;
  8. case 2:
  9.   include('linux.php');
  10.   break;
  11. case 3:
  12.   include('dos.php');
  13.   break;
  14. default:
  15.   include('home.php');
  16.   break;
  17. }
  18. ?>

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 119 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.