How D'you Put The Url The Page Into A Link W/ Php?

Discussion in 'Gaming' started by Tastypoo, Oct 7, 2006.

  1. Tastypoo

    Tastypoo Well-Known Member

    Age:
    35
    Posts:
    296
    Likes Received:
    0
    Joined:
    Aug 16, 2005
    Location:
    Michigan
    I ended up successfully making it. If you want, you can download it here.

    ----------------------

    I know this probably sounds stupid, but I want to add those little digg, del.icio.us, furl etc. "add" button things to my site. I just don't want to have to go into all the hundreds of pages of my site and manually add each one.

    So I was wondering, does anyone know a way, like with PHP, Javascript, or whatever, to make it so you can make just a link in your PHP include, like:


    Code:
    <a href="http://www.dig.com/add.php?id=343?=<? code that will put the URL of my page into the link ?>[img]images/addtodig.jpg[/img]</a>
    

    so that then it will add that to every page? I think it'd be cool, and it could increase traffic greatly to my site. If this doesn't make sense and you want to help or think you might know a way how, PM me.

    Thanks in advance.

    EDIT: I guess no one wants to help. I'll give 10 creds to whoever can find this for me.
     
  2. ale_jrb

    ale_jrb Senior Member

    Age:
    34
    Posts:
    306
    Likes Received:
    0
    Joined:
    Jul 23, 2005
    Location:
    London, UK
    The PHP code:

    Code:
    <?php echo $PHP_SELF ?>
    Will print the URL of a website. You just have to put it in the link that you want, so in your example, it would be:

    Code:
    <a href="http://www.dig.com/add.php?id=343?=<?php echo $PHP_SELF ?>[img]images/addtodig.jpg[/img]</a>
    Hope this helps! :)
     
  3. Tastypoo

    Tastypoo Well-Known Member

    Age:
    35
    Posts:
    296
    Likes Received:
    0
    Joined:
    Aug 16, 2005
    Location:
    Michigan
    Okay thanks... I already went and made a really complicated code using different ones that works exactly the same. But thanks man. I'll send you some creds.

    EDIT: Yeah, that doesn't work. You forgot to put [ ] around the code, and I still don't think that that's a working code.
     
  4. ale_jrb

    ale_jrb Senior Member

    Age:
    34
    Posts:
    306
    Likes Received:
    0
    Joined:
    Jul 23, 2005
    Location:
    London, UK
    Your host will have to have register globals set to on. Ask them about it.

    And it does work, becuse I've done similar things before. Keep in mind that it will give the exact URL, not your domain.
     
  5. Tastypoo

    Tastypoo Well-Known Member

    Age:
    35
    Posts:
    296
    Likes Received:
    0
    Joined:
    Aug 16, 2005
    Location:
    Michigan
    Okay, I guess my host doesn't have that then or something, 'cause I just copied what you put, and the URL was http://www.dig.com/add.php?id=343?=.. which means that the code didn't load.

    Thanks a lot for the help though.
     

Share This Page