Results 1 to 9 of 9

Thread: changing url php page ...

  1. #1
    Join Date
    Oct 2005
    Posts
    255
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default changing url php page ...

    OK, here I go.

    My urls on my pages are, index.php, about.php, contact.php, graphics.php.

    I want to know how do i do(i think php includes get????) it so I can have the url looking like this when I goto a page on my site...

    http://www.mydomain.com/index.php
    http://www.mydomain.com/index.php?page=about
    http://www.mydomain.com/index.php?page=contact
    http://www.mydomain.com/index.php?page=graphics

    Please list a little script if possible..
    Hey new design new look, goto xudas for personal webdsign help.. (:

  2. #2
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Something along the lines of this:

    Code:
    <?php
    
    $pages = Array(
    'about' => 'about.php',
    'contact' => 'contact.php',
    'graphics' => 'graphics.php'
    );
    
    if (isset($_GET['page']) && array_key_exists($_GET['page'],$pages)) {
       include($pages[$_GET['page']]);
    }
    else {
       include('defaultpage.php');
    }
    ?>
    Simply edit the items highlighted above to point to your files. Also, edit where it says defaultpage.php to whatever you want your default page to be; such as main.php or whatever.
    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  3. #3
    Join Date
    Oct 2005
    Posts
    255
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    ty i will test this out...
    Hey new design new look, goto xudas for personal webdsign help.. (:

  4. #4
    Join Date
    Oct 2005
    Posts
    255
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    is there a way instead of include but got the page..

    say i want to goto about page and i click the about button, I would like it to send me to that page with index.php?page=about instead of including the page..
    Hey new design new look, goto xudas for personal webdsign help.. (:

  5. #5
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Do you mean masking the url? So that instead of this: about.php it is like so: index.php?page=about?

    If so, you may need to look into htaccess for this. Other than that, the best way would be to do includes.
    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  6. #6
    Join Date
    Oct 2005
    Posts
    255
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    NEVERMIND, I LUV YOU!!! lol,jk but Thankyou oh so much!!!!!!!!
    Hey new design new look, goto xudas for personal webdsign help.. (:

  7. #7
    Join Date
    Oct 2005
    Posts
    255
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    oh another thing, sorry lol.. how would I go about do this.....

    say I wanted to goto this page

    index.php?page=graphics

    then I click on another link. to graphics>> cursors

    index.php?page=graphics?=cursors

    is there a possible way to do this?



    nevermind figured it out!!!!!
    Last edited by insanemonkey; 09-24-2007 at 09:59 PM. Reason: hehee
    Hey new design new look, goto xudas for personal webdsign help.. (:

  8. #8
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    In whatever page you have; let's say graphics.php, you need to call the variables like so:

    Code:
    <?php
     echo $_GET['var'];
    ?>
    Then you can call the page like so:

    Code:
    <a href="index.php?page=graphics&amp;var=whatever">Text</a>
    That will produce on the page (when called):

    whatever
    Hope this helps.

    (NOTE: this was only an expample, the possibilities are endless when you get going on it.)
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  9. #9
    Join Date
    Oct 2005
    Posts
    255
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Actually what I did was just add another thing under page arrays
    and it looks like this

    'contact?=submitform' => 'urlblahblah.php',

    and it works kool, thanks guys!!
    Hey new design new look, goto xudas for personal webdsign help.. (:

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •