well um i made a layout.......now i added the pages with

<?php include("main.php"); ?>

okay that works now what i want to do is.....

well since i have contents i want to be able to navigate and i want to use less pages etc......

so i just want to know how to make a url go into the include.....

think about IFRAMING i want to do that i want links to be able to stay in the same page other than a pop up or w.e

am i making any sence?

    OK, good. I am glad you found it.

    But do yourself a favor and don't use the first example:

    <?php
    $page = $_GET['page'];	/* gets the variable $page */
    if ($page) {
    	include($page);
    } 	/* if $page has a value, include it */
    else {
    	include('page1.php');
    } 	/* otherwise, include the default page */
    ?>
    

    Do use THIS example with the array to check your approved of pages:

    <?php
    $page = $_GET['page'];
    // create array of APPROVED of pages for 
    // inclusion!!
    $pages = array('page1', 'page2', 'page3');
    if ($page) {
    	if(in_array($page,$pages)) {
    		$page = $page . '.php';
    		include($page);
    	}
    	else {
    	echo 'Page not found. Return to
    	<a href="index.php">index</a>';
    	}
    }
    	else {
    		include('page1.php');
    	}
    ?>

    That is MUCH safer!!

    🙂

      well.....the first one works for me and the second one the echo shows

      why?

        Did you change the $pages array to actual values of the pages you want to show users??

        If so, post your exact code and we shall take a look.

          <?php
          $page = $_GET['page'];
          // create array of APPROVED of pages for
          // inclusion!!
          $pages = array('page1', 'page2', 'page3');
          if ($page) {
          if(in_array($page,$pages)) {
          $page = $page . '.php';
          include($page);
          }
          else {
          echo 'Page not found. Return to
          <a href="index.php">index</a>';
          }
          }
          else {
          include('page1.php');
          }
          ?>

          same code i only changed the page1.php into main.php and i used this as the linkin thing

          <a href="index.php?page=about.php"><b>A</b>bout us</a> \
          <a href="index.php?page=tag.php"><b>T</b>agger</a>

            This is a full url with query string taken from your site after I have clicked the links "link": http://free.hostultra.com/~Unify/pg/index.php?page=links.php

            Your $_GET['page'] value is links.php Which means your script is looking to include: links.php.php

            You need to reconfigure the links to remove the .php file extensions from the links, and your links will look like the following:

            <a href="index.php?page=main"><b>N</b>ews</a> \
            <a href="index.php?page=cdkeys"><b>S</b>erials</a> <br> 
            <a href="index.php?page=porn"><b>P</b>orno</a>  \
            <a href="index.php?page=bd"><b>B</b>reak Dancing</a><br>
            <a href="index.php?page=humor"><b>H</b>umor</a>  \
            <a href="index.php?page=links"><b>L</b>inks</a><br>  
            <a href="index.php?page=linkme"><b>L</b>ink Me</a> \ <a href="index.php?page=contact"><b>C</b>ontact</a><br> <a href="index.php?page=about"><b>A</b>bout us</a> \ <a href="index.php?page=tag"><b>T</b>agger</a>

              hmm well i fixed the nav thing.....but it still says page not found 🙁

              any other ideas?

                unify34 wrote:

                hmm well i fixed the nav thing.....but it still says page not found 🙁

                any other ideas?

                Post the latest version of your code (and use the

                 tags to enclose them to make the code easier to see..)

                  index.php code

                  <?php 
                  $page = $_GET['page']; 
                  // create array of APPROVED of pages for 
                  // inclusion!! 
                  $pages = array('page1', 'page2', 'page3'); 
                  if ($page) { 
                      if(in_array($page,$pages)) { 
                          $page = $page . '.php'; 
                          include($page); 
                      } 
                      else { 
                      echo 'Page not found. Return to 
                      <a href="index.php">index</a>'; 
                      } 
                  } 
                      else { 
                          include('main.php'); 
                      } 
                  ?>

                  nav.php code

                  <a href="index.php?page=main"><b>N</b>ews</a> \
                  <a href="index.php?page=cdkeys"><b>S</b>erials</a> <br> 
                  <a href="index.php?page=porn"><b>P</b>orno</a>  \
                  <a href="index.php?page=bd"><b>B</b>reak Dancing</a><br>
                  <a href="index.php?page=humor"><b>H</b>umor</a>  \
                  <a href="index.php?page=links"><b>L</b>inks</a><br>  
                  <a href="index.php?page=linkme"><b>L</b>ink Me</a> \ <a href="index.php?page=contact"><b>C</b>ontact</a><br> <a href="index.php?page=about"><b>A</b>bout us</a> \ <a href="index.php?page=tag"><b>T</b>agger</a>

                    Try this:

                    <?php
                    // if the page is set in q-string
                    if(isset($_GET['page'])){
                    	$page = trim($_GET['page']);
                    }
                    // else page is not set
                    else {
                    	$page = 'main';<?php
                    // if the page is set in q-string
                    if(isset($_GET['page'])){
                    	$page = trim($_GET['page']);
                    }
                    // else page is not set
                    else {
                    	$page = 'main';
                    }
                    
                    // APPROVED of pages for inclusion
                    $pages = array('main', 'cdkeys', 'porn', 'bd'); // etc... 
                    
                    // if acceptable request, page in array
                    if(in_array($page,$pages)) {
                    	$file = $page . '.php'; 
                    	include($file); 
                    } 
                    else { 
                        echo 'Page not found. Return to <a href="index.php">index</a>'; 
                    }
                    ?>
                    <p>
                    <a href="index.php?page=main"><strong>N</strong>ews</a> 
                    <a href="index.php?page=cdkeys"><strong>S</strong>erials</a><br /> 
                    <a href="index.php?page=porn"><strong>P</strong>orno</a>  
                    <a href="index.php?page=bd"><strong>B</strong>reak Dancing</a><br /> <a href="index.php?page=humor"><strong>H</strong>umor</a>
                    <a href="index.php?page=links"><strong>L</strong>inks</a><br />
                    <a href="index.php?page=linkme"><strong>L</strong>ink Me</a>
                    <a href="index.php?page=contact"><strong>C</strong>ontact</a><br /> <a href="index.php?page=about"><strong>A</strong>bout us</a>
                    <a href="index.php?page=tag"><strong>T</strong>agger</a></p>

                      i guess the nav.php is the same.......although i did get an unexpecting "<" in the code so i fixed it into.....

                      <?php 
                      // if the page is set in q-string 
                      if(isset($_GET['page'])){ 
                          $page = trim($_GET['page']); 
                      } 
                      // else page is not set 
                      else { 
                          $page = 'main';
                      
                      }
                      
                      ?>
                      
                      
                      <?php 
                      // if the page is set in q-string 
                      if(isset($_GET['page'])){ 
                          $page = trim($_GET['page']); 
                      } 
                      // else page is not set 
                      else { 
                          $page = 'main'; 
                      } 
                      
                      // APPROVED of pages for inclusion 
                      $pages = array('main', 'cdkeys', 'porn', 'bd'); // etc... 
                      
                      // if acceptable request, page in array 
                      if(in_array($page,$pages)) { 
                          $file = $page . '.php';  
                      include($file);
                      }
                      else {
                      echo 'Page not found. Return to <a href="index.php">index</a>';
                      } ?>

                      as you see there is now 2 seperate php codes...... think we can just connect it?

                      um also it works but only for these pages

                      $pages = array('main', 'cdkeys', 'porn', 'bd'); // etc

                      the other just shows the echo.... and i tried editing the names in the array but i had an invalid T string......

                      any other ideas =) were close though

                      please and thanks

                        unify34 wrote:

                        i guess the nav.php is the same.......although i did get an unexpecting "<" in the code so i fixed it into.....

                        Not sure what you mean here by ' unexpecting "<" in the code' ?

                        unify34 wrote:
                        <?php 
                        // if the page is set in q-string 
                        if(isset($_GET['page'])){ 
                            $page = trim($_GET['page']); 
                        } 
                        // else page is not set 
                        else { 
                            $page = 'main';
                        
                        }
                        ?>
                        <?php 
                        // if the page is set in q-string 
                        if(isset($_GET['page'])){ 
                            $page = trim($_GET['page']); 
                        } 
                        // else page is not set 
                        else { 
                            $page = 'main'; 
                        } 
                        // *snip*
                        
                        

                        as you see there is now 2 seperate php codes...... think we can just connect it?

                        Heck yes! That is redundant code. You are doing the same thing twice. Remove the top one.

                        unify34 wrote:

                        um also it works but only for these pages

                        $pages = array('main', 'cdkeys', 'porn', 'bd'); // etc
                        

                        Yes, I know that. The comment "// etc" means that YOU have to fill out the array with ALL of the pages that you have links to... Otherwise, the page request will be bad...

                        unify34 wrote:

                        i tried editing the names in the array but i had an invalid T string

                        Well, if you don't put the pages in the array, they won't be available to view. The "T-String" error probably means that you didn't enter an opening or closing quote, or there was a comma in the wrong place in your array definition. There cannot be a comma ',' after the LAST item in the array definition. OK? Make sure that each item is entered corectly in the array definiton:

                        // define an array:
                        $some_array = array('one', 'two', 'three', 'four', 'five', 'six');
                        

                        Try again. You are close, but you have to finish this. You can do it.

                          thanks for the encouragement 🙂

                          and thanks for the help its workin now

                          🙂 thanks alot man heheh

                            Write a Reply...