...

View Full Version : How to get code to be visible on a web page



adamclark
08-05-2010, 11:21 AM
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.

nikee
08-05-2010, 02:04 PM
Are you talking about the URL to your website?

use php to get and display it:


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

echo $url;

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


<form>
<input type="text" value="<?php echo $url; ?>" />
</form>

adamclark
08-05-2010, 02:37 PM
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>

SB65
08-05-2010, 02:38 PM
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:


&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)

jfreak53
08-05-2010, 02:51 PM
The easiest way is to use a text area or input like stated above that is what most sites do.

jfreak53
08-05-2010, 02:52 PM
<textarea><a href="index.html">me</a></textarea>

nikee
08-05-2010, 02:56 PM
Sorry, i made a few mistakes in the last post. It works now:




<?php

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

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

?>

adamclark
08-05-2010, 03:12 PM
cool - got it working. Thanks all.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum