Forum Moderators: coopster

Message Too Old, No Replies

Including a page's url in a hyperlink on it

For adding links to bookmark sites

         

Rog82

4:26 pm on Oct 1, 2007 (gmt 0)

10+ Year Member



Hi,

I'm trying to add links to my site to recommend articles to stumbleupon, digg etc and need to automaticaly include the url of the page in the link to recommend it so the link on the page www.example.com/details.php?id=55
looks something like:

www.example.com/submit?url=www.example.com/details.php?id=55

is there a universal way to write this?

Any help would be greatly appreciated.

[edited by: Rog82 at 4:37 pm (utc) on Oct. 1, 2007]

[edited by: dreamcatcher at 7:25 am (utc) on Oct. 2, 2007]
[edit reason] Use example.com, thanks. [/edit]

OutdoorWebcams

4:45 pm on Oct 1, 2007 (gmt 0)

10+ Year Member



You could try something like:

$thisurl = "http://www.example.com".$_SERVER['REQUEST_URI']);
$link = "www.example.com/submit?url=$thisurl";

[edited by: dreamcatcher at 7:26 am (utc) on Oct. 2, 2007]
[edit reason] Use example.com, thanks. [/edit]

Rog82

4:51 pm on Oct 1, 2007 (gmt 0)

10+ Year Member



Thanks that's really helpful, I'll let you know how I get on.

phranque

4:29 am on Oct 2, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



this might work better if you have non-alphanumeric characters in the url:
$thisurl = "http://www.example.com" . $_SERVER['REQUEST_URI']);
$link = "www.example.com/submit?url=" . urlencode($thisurl);

[edited by: dreamcatcher at 7:26 am (utc) on Oct. 2, 2007]
[edit reason] Use example.com, thanks. [/edit]

Rog82

10:52 am on Oct 2, 2007 (gmt 0)

10+ Year Member



This doesn't seem to be working, I put the

$thisurl = "http://www.example1.com" . $_SERVER['REQUEST_URI']);

line in above the box with the links in and it just printed the line on the page

also should the link look like:

<a href="http://www.example2.com/submit?url=". urlencode($thisurl);> Example 2</a>

(where example1 is my site and example2 is the destination site)

thanks

Habtom

11:26 am on Oct 2, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



$thisurl = "http://www.example1.com" . $_SERVER['REQUEST_URI']);

You don't need the ending bracket.

$thisurl = "http://www.example1.com" . $_SERVER['REQUEST_URI'];

phranque

12:11 pm on Oct 2, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



$thisurl = "http://www.example.com" . $_SERVER['REQUEST_URI']);
$link = "www.example.com/submit?url=" . urlencode($thisurl);

[edited by: dreamcatcher at 7:26 am (utc) on Oct. 2, 2007]
[edit reason] Use example.com, thanks. [/edit]

except that it's a different example.com, so you just confused my "example", thanks.

let's try this:

$thisurl = "http://www.example.com" . $_SERVER['REQUEST_URI'];
$link = "bookmark.example.com/submit?url=" . urlencode($thisurl);

Rog82

11:36 am on Oct 3, 2007 (gmt 0)

10+ Year Member



Thanks, I think I'm almost there, but writing links in the form:

$link = "bookmark.example.com/submit?url=" . urlencode($thisurl);

doesn't create a link, I just get that printed on the page. Is there a way to write it in the form:

<a href="bookmark.example.com/submit?url=" . urlencode($thisurl);>bookmark.example</a>

currently trying this it links exactly as it is writen rather than replacing the last bit with the pages URL.

Cheers

[edited by: Rog82 at 11:37 am (utc) on Oct. 3, 2007]