Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-05-2010, 11:21 AM   PM User | #1
adamclark
New Coder

 
Join Date: Mar 2010
Posts: 11
Thanks: 1
Thanked 0 Times in 0 Posts
adamclark is an unknown quantity at this point
How to get code to be visible on a web page

Hi,

I want to show visitors to my site the code they need to use to make a link to my site.

Trouble is - when i use the code, it is converted into a link - i want the actual code for the link to be visible on the webpage so the visitor can copy it.

Any help appreciated.

Thanks.
adamclark is offline   Reply With Quote
Old 08-05-2010, 02:04 PM   PM User | #2
nikee
Regular Coder

 
Join Date: Jan 2009
Posts: 173
Thanks: 5
Thanked 12 Times in 11 Posts
nikee is an unknown quantity at this point
Are you talking about the URL to your website?

use php to get and display it:
Code:
<php>
$url = "http://" . $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];

echo  $url;

</php>
or echo it into an input field:

Code:
<form>
<input type="text" value="<?php echo $url; ?>" />
</form>
nikee is offline   Reply With Quote
Old 08-05-2010, 02:37 PM   PM User | #3
adamclark
New Coder

 
Join Date: Mar 2010
Posts: 11
Thanks: 1
Thanked 0 Times in 0 Posts
adamclark is an unknown quantity at this point
I've not used php before and i've tried the form code you mentioned but it doesn't seem to work.

The exact code i want to appear on the page is:

<p>We're a partner of <a href="http://www.findashopfitter.co.uk" target="_blank">Findashopfitter.co.uk for (insert your county or counties here).</a></p>
adamclark is offline   Reply With Quote
Old 08-05-2010, 02:38 PM   PM User | #4
SB65
Senior Coder

 
Join Date: Feb 2009
Location: West Yorkshire
Posts: 2,817
Thanks: 9
Thanked 681 Times in 675 Posts
SB65 will become famous soon enoughSB65 will become famous soon enough
Or, if you don't want to mess with php, then you need to convert the < and > symbols to their html equivalents - then the page will show the code not a link.

So, to display:<a href="mylink">Link text</a>

you need the following on your page:

Code:
&lt;a href="mylink"&gt;Link text&lt;/a&gt;
You'll see that < is replaced by &lt; and > by &gt; (less than and greater than symbols)
SB65 is offline   Reply With Quote
Old 08-05-2010, 02:51 PM   PM User | #5
jfreak53
Regular Coder

 
jfreak53's Avatar
 
Join Date: May 2004
Location: Guatemala
Posts: 477
Thanks: 19
Thanked 10 Times in 10 Posts
jfreak53 is an unknown quantity at this point
The easiest way is to use a text area or input like stated above that is what most sites do.
__________________
"FORTRAN is not a language. It's a way of turning a multi-million dollar mainframe, into a $50 programmable scientific calculator."
http://www.microfastcat.com -- FastCat Software, the fastest software on the NET!
http://www.microthosting.com -- Free reseller web hosting, Hosting, VPS, FREE SMALL HOSTING!!!
http://www.microtronix-tech.com -- Web design and programming
jfreak53 is offline   Reply With Quote
Old 08-05-2010, 02:52 PM   PM User | #6
jfreak53
Regular Coder

 
jfreak53's Avatar
 
Join Date: May 2004
Location: Guatemala
Posts: 477
Thanks: 19
Thanked 10 Times in 10 Posts
jfreak53 is an unknown quantity at this point
Code:
<textarea><a href="index.html">me</a></textarea>
__________________
"FORTRAN is not a language. It's a way of turning a multi-million dollar mainframe, into a $50 programmable scientific calculator."
http://www.microfastcat.com -- FastCat Software, the fastest software on the NET!
http://www.microthosting.com -- Free reseller web hosting, Hosting, VPS, FREE SMALL HOSTING!!!
http://www.microtronix-tech.com -- Web design and programming
jfreak53 is offline   Reply With Quote
Old 08-05-2010, 02:56 PM   PM User | #7
nikee
Regular Coder

 
Join Date: Jan 2009
Posts: 173
Thanks: 5
Thanked 12 Times in 11 Posts
nikee is an unknown quantity at this point
Sorry, i made a few mistakes in the last post. It works now:

Code:
<?php

$url = "http://" . $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];

echo "<form>";
echo  "<input type='text' value='" . $url . "' />";
echo "</form>";

?>
nikee is offline   Reply With Quote
Old 08-05-2010, 03:12 PM   PM User | #8
adamclark
New Coder

 
Join Date: Mar 2010
Posts: 11
Thanks: 1
Thanked 0 Times in 0 Posts
adamclark is an unknown quantity at this point
cool - got it working. Thanks all.
adamclark is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:25 AM.


Advertisement
Log in to turn off these ads.