Thread: URL Encoding

    #1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    12
    Rep Power
    0
    Hello,
    Can anyone point me in the direction of a tutorial on URL encoding? I am creating a website and i want to use 1 page which contains the layout, then seperate pages with the content. i would do it something similar to this:

    http://website.com/index.php?page=links

    Then that would just call up a .inc page specified in the page= variable and display it on index.php.

    I am learning php through the internet instead of books, and i already have basic knowledge of how to create stuff, and the syntax i am farmiliar with. So if someone could link me to a page to learn about URL encoding, i would greatly appreciate it.

    Thanks,
    -Bryan
  2. #2
  3. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,642
    Rep Power
    4492
    When you pass a value in the url, php automatically creates that variable and it's value. if you have
    http://website.com/index.php?page=links

    then on index.php, there will be a variable $page with value "links". in your index.php page you have something like this.

    <html>
    <body>
    <?php
    if ($page == "links") { include("link.inc"); }
    if ($page == "banners") { include("banners.inc"); }
    ?>
    </body>
    </html>

    one thing i always say about include files, if you name them with a .inc extension, be sure that your web server is set up to parst .inc files as php. it really won't matter for the include() statements, as the original file is already being parsed, but if someone finds out the name of your include file, links.inc and enteres that into their browser, it'll be sent to them plain text and they'll be able to see your code. another option is to just name your include files with a .php extension. i use "inc_database.php". a last option would be to place your include files outside of your web directory, that way, even if someone finds out the name of your file, it can't be pulled up in a browser becuase it's not in the web directory.

    hope that helps..

    ---John Holmes...
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    12
    Rep Power
    0
    Thanks John. I appreciate your input, but I had unfortunetly figured out url encoding before you replied. What i did was create a php3 file called show.php3 and just had it redirect to the new page depending on the ID. I decided not to do the include thing, because it would mess over my hit counter i made if each page was all on the index.php3 page =]

    Thanks again,
    -Bryan

Similar Threads

  1. Change ip url to domain
    By crypt1c_c0d3 in forum Apache Development
    Replies: 2
    Last Post: January 2nd, 2004, 09:55 AM
  2. Issue with URL address using LWP
    By usaindp1776 in forum Perl Programming
    Replies: 4
    Last Post: September 3rd, 2003, 07:51 PM
  3. mod_rewrite and current URL
    By mikix in forum Apache Development
    Replies: 1
    Last Post: August 4th, 2003, 09:29 PM
  4. URL Handling
    By ranjankumar17 in forum HTML Programming
    Replies: 4
    Last Post: August 1st, 2003, 10:56 AM
  5. Need help: redirect to page based on text in URL
    By JPElectron in forum HTML Programming
    Replies: 2
    Last Post: July 18th, 2003, 11:44 PM

IMN logo majestic logo threadwatch logo seochat tools logo