dcsimg
www.webdeveloper.com
Results 1 to 7 of 7

Thread: Directing links

  1. #1
    Join Date
    Jun 2010
    Posts
    3

    Directing links

    I have some dynamically created links that I am having trouble getting to direct properly.

    I want each link to re-direct to essentially the same page, just with different text associated with the link.

    I'm assuming the process would be clicking on a link should set a variable associated with that link. The page that loads from each link should be the same "base" page but fills in the data based on the variable of the clicked link.

    I'm assuming this is a relatively common procedure but can't seem to find any information on it. I'm fairly new to programming so I'm not even sure what language I should be using. I'd appreciate any help or direction as to where to begin looking/learning.

    Thanks

  2. #2
    Join Date
    May 2010
    Posts
    123
    Hi, I am not sure what you mean.

    Do you mean 'basepage.php?id=5' etc will do something on the page depending on what ID you give it?

  3. #3
    Join Date
    Jul 2009
    Location
    Falls Church, Va.
    Posts
    780
    @OP: If true, it is relatively common, and also very prone to hacking and SQL injection if a database is involved and depends on the variable. So use for simple applications where security isn't crucial, otherwise consider working with sessions and/or hashes being passed instead of values.

  4. #4
    Join Date
    Jun 2010
    Posts
    3
    Should have known my description would be confusing. How about a similar example: If I search for something on youtube, i get a bunch of links (already have this page set up). All of those links essentially take you to the same page (layout), but fill in the video/comments.

    I'm trying to figure out how to have each link take you to this "layout" page but fill in properly (and have their own unique url). Is this the correct way of thinking about it?

    I'm unfamiliar with both of your suggestions, so I'll start looking into them. Thanks for the help.

  5. #5
    Join Date
    Apr 2008
    Location
    Mumbai, India
    Posts
    259
    Quote Originally Posted by bshig View Post
    Should have known my description would be confusing. How about a similar example: If I search for something on youtube, i get a bunch of links (already have this page set up). All of those links essentially take you to the same page (layout), but fill in the video/comments.

    I'm trying to figure out how to have each link take you to this "layout" page but fill in properly (and have their own unique url). Is this the correct way of thinking about it?

    I'm unfamiliar with both of your suggestions, so I'll start looking into them. Thanks for the help.
    You might be aware about displaying the contents of the page (video/comments) when clicked on the link on the same page by using e.g., basepage.php?id=5 (unique id).

    To get the unique url, you can use the results from the database (a href = "url-from-database">link</a>) since the search results are from database I hope. And then you can use the .htaccess rewrite rule to redirect to the same page.

    e.g., RewriteRule ^([a-zA-Z0-9_-]+).html$ page.php?products_id=$1.html&%{QUERY_STRING}


    Hope this may helps....

  6. #6
    Join Date
    Jul 2009
    Location
    Falls Church, Va.
    Posts
    780
    Quote Originally Posted by bshig View Post
    Should have known my description would be confusing. How about a similar example: If I search for something on youtube, i get a bunch of links (already have this page set up). All of those links essentially take you to the same page (layout), but fill in the video/comments.I'm trying to figure out how to have each link take you to this "layout" page....
    Continuing with the YouTube analogy, a URL might look like this:

    http://www.youtube.com/watch?v=aKBQrXxrvu0

    In the "watch" directory is the layout script (keeping it simple). That script sees argument "v" (you'd use $_GET['v'] in PHP) and its associated unique identifier (value) "aKBQrXxrvu0". This value is stored in a database, the script validates it and pulls the proper video and contents from various tables via joins, parsing and displaying in place (i.e. the Flash which displays the video, show the comments, who posted the video, etc. all within the layout). The key being all of this is done internally, note that v is not set to the ID of the video in the table, but a hash that references it. That's the security I was referring to.

    So sure, you can and should do something like this on the back end.

    Shanu.chaudhary's response had to do with even more security that allows either friendly URL's or a form of URL masking using Apache's mod_rewrite which is quite handy in situations like this. But on the back end, it's still the same no matter how the URL is redirected or not. That is the point we're both making to you which matters most.

    Hope this helps.

    -jim

  7. #7
    Join Date
    Jun 2010
    Posts
    3
    This is hugely helpful guys, thanks a lot. Exactly what I was looking for.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles