What is the best way to handle site navigation?

When I first started learning web development I had html-files which I linked to. Later on I sent variables through the url and used a php-script with $_GET to load the appropriate content. Let's say that the url looked like this: http://www.example.com/?page=home. So the user was always located at the index page but the server were including different content depending upon the ?page variable.

Are some ways worse to handle navigation than others? Is the last mentioned way ineffective?

I've always wondered about nodes (at least I think it's called that). That saying that if I want to load a users profile page, the aforementioned way of doing it would like something like: http://www.example.com/?user=someone. But then if I have understood nodes correctly you could write http://www.example.com/someone/ and still be directed to the correct page through a script or something.

Please help me understand web navigation better and maybe teach me or post a link to a good tutorial about nodes because I can't seem to find any.

Thanks!

Member Avatar for rajarajan2017

http://www.example.com/?user=someone

This is the rightway to call a user profile, bcoz your users are stored in a database and if you want to retreive or store the details of the user. This way is much useful to pass the user value to another page, with that value some jobs are done in the loaded page.

http://www.example.com/someone/

In this case, you are giving the absolute path and a seperate page is needed for someone. Is not the case in above, any user details can be shown in a single page.

In this case,
http://www.example.com/Raja/
http://www.example.com/John/
http://www.example.com/Emily/

for every user you have to create a seperate webpage, Is it the way to create thousands of user to create thousands pages?

The above ? method is querystring which will further handle the programming logic in the loaded page

Yeah I know that
http://www.example.com/someone/

links to the directory someone but somewhere I read about "nodes" which simplifies for the user so that he only needs to write the above url instead of having to write
http://www.example.com/?user=some&color=blue&database=sayWhut&redirect=true

Do you understand what I'm saying? I think that either the server redirects the user by processing the url or getting an entry from a database with "abbreviations" of urls. At least I think this is how it works, I believe Drupal has a similar function.

But what I said earlier about controlling the whole navigation by including different files into the index file, is that effective or is there another general way of handling navigation?

Member Avatar for rajarajan2017

Yeah, I Understood. I am not having more idea about that, anyway I will get you back with some inputs

It's called friendly urls. It's done through mod_rewrite with apache. Search in php forum, as there have been many threads on this already. I haven't worked on it , so this is all I can say.

Thank you! This is what I've been searching for! thank you very much! I will start using this in my future projects now :D

But how about alternate ways of handling navigation? What are the most used techniques?

Search by the related keyword in google, because I saw more result what expected. Thanks.

But how about alternate ways of handling navigation? What are the most used techniques?

I am not really sure of your question. As far as I know, there is either
* long, dirty urls, like,
http://www.somewebsite.com/edit.php?id=1234&key=xy&somevar=v
or
* friendly urls, like,
http://www.somewebsite.com/edit/1234/xy/v

I am not aware of any other navigation techniques.

Are some ways worse to handle navigation than others? Is the last mentioned way ineffective?

As long as you take good measures to sanitize user's inputs it's okay. For example,

<?php
//mysql connection
//get the page from the url, sanitize it with mysql_real_escape_string
$page = mysql_real_escape_string($_GET['page']);
// $page = home or report
switch($page) {
   case "home":
      //include/print home's contents
    break;
    case "report":
    //include/print report's contents
   break;
   default:
   //show error page
   break;
}

In the above example, a user can only access to only 2 pages, "home" and "report". If he tries anything else, it will take him to the error page [the default case].

Cheers,
Naveen

Thanks for the answer nav33n! That is how I handle navigation at the moment but I didn't read it anywhere or learned from a tutorial, it was just something I figured out myself so I never knew if any other used that technique. But now I know, thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.