How can we clean up the address line?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Pavon
Forum Newbie
Posts: 1
Joined: Sat Nov 30, 2002 2:54 am

How can we clean up the address line?

Post by Pavon »

Is it possible to clean up the address line on the browser, so that it does not reveal the querystrings and variables that are passed from page to page?

Thanks!

Fernando
MeOnTheW3
Forum Commoner
Posts: 48
Joined: Wed Nov 13, 2002 3:28 pm
Location: Calgary, AB

Post by MeOnTheW3 »

If you can not use POST methods, I believe there is a javascript method to actually change the browser.location.???? without actully changing the document.url, which would not be the desired result.

Good luck, I would be interested in knowing what your final decision was.
dezel
Forum Newbie
Posts: 1
Joined: Sat Nov 30, 2002 8:33 am
Location: Dublin, Ireland, Europe

Cleaning up a URL

Post by dezel »

Yes you can easily clean up a url using PHP's inbuilt functions, i.e. explode.

Code: Select all

$var_array = explode("/", $PATH_INFO);
Consider the following for example.
You have a file called articles.php which when given two vars, section and page, will display a particular story fetched from your database. (E.G. articles.php?section=php+is+cool&page=1234), But if it is only given the section variable, then it should display a list of articles under that section.

Yes you can use MOD_REWRITE, or Javascript, or you can use php. The way I got around it was to rename articles.php to just articles. Added a .htaccess and added a ForceType application/x-httpd-php directive for my file. This would allow my url to look like this :

/articles/section+name/1234.html

Heres a sample of the code. I am afriad its not great as I wrote this ages ago when I still did not know much about PHP>

Code: Select all

<?php
$var_array = explode("/", $PATH_INFO);
$file=$var_arrayї0];
$section=$var_arrayї1];
check_section($section);
$articleid=$var_arrayї2];
if($section && $articleid)
    {
    // Ok a section has been selected. List all the articles for this section.
    $query = mysql_query("SELECT * from articles where articleid='$articleid'" and section='$section') or die ("could not execute");
    }
else .....
?>
Post Reply