Link Box

Written by @m_k_amin 19 December 2012

Do you ever seen link boxes on the sites and weblogs? They are used for sharing links between you and other (related) sites. This script is a link box for your site. You can either add links directly to the page or put them in an IFrame by it. The difference is that IFrames are not SEO friendly and some search engines may not index the links correctly; but, they have scroll bars and doesn't elongate the page. In other hand, when you put direct links in your page, your page will be well indexed; however, the page stretch to include all links. Another point about this link box is that it is just one page script and it automatically made what ever it needs. Read this script carefully if you want to know more about PHP files usage. Enjoy!

Code Snippet:

                                                
                                                <!-- this script is provided by https://www.phpfreecode.com coded by: Kerixa Inc. -->
<!-- This Script is from www.phpfreecpde.com, Coded by: Kerixa Inc-->

<?php
if (isset($_POST['Submit'])){
	if ($_POST['place']=='DI')
		$filename='DI.txt';
	else
		$filename='IF.txt';
	
	$url=$_POST['url'];
	$txt=$_POST['txt'];
	$link="<a href='$url'>$txt</a>";
	$handle = fopen("$filename", "a");
	fwrite($handle, "$link\n");
	fclose($handle);
}
$DI='';
$IF='';
if (file_exists('DI.txt')){
	$handle = fopen('DI.txt', "r");
	$DI = fread($handle, filesize('DI.txt'));
	fclose($handle);	
}
if (file_exists('IF.txt')){
	$handle = fopen('IF.txt', "r");
	$IF = fread($handle, filesize('IF.txt'));
	fclose($handle);	
}
$DI=str_replace("\n","<br>",$DI);
$IF=str_replace("\n","<br>",$IF);
$handle = fopen("lnk.htm", "w");
fwrite($handle, $IF);
fclose($handle);
?>

<form action="" method="post">
<table style="border: 1px solid #000000;width: 710px" align="center">
	<tr>
		<td style="font-family: 'Times New Roman', Times, serif;font-size: 17pt;text-align: center;width: 353px; color: #2214B9;border-style: solid;border-width: 1px;">
		Direct Links</td>
		<td style="font-family: 'Times New Roman', Times, serif;font-size: 17pt;text-align: center;color: #2214B9;border-style: solid;border-width: 1px; width: 353px;">
			IFrame Links</td>
	</tr>
	<tr>
		<td style=" padding-left:8px; padding-top:2px; width: 353; border-style: solid;border-width: 1px;text-align: left; height: 39; font-size: 11pt;" valign="top">
<?php if (isset($DI)) echo $DI; else echo"&nbsp;" ?>
		</td>
		<td style="border-style: solid;border-width: 1px; height: 39px;padding-left: 8px; width: 353px;">
		<iframe id="I1" border="0" frameborder="0" name="I1" src="lnk.htm" style="width: 340px" marginheight="0" marginwidth="0">Your browser does not support inline frames or is currently configured not to display inline frames.
			</iframe></td>
	</tr>
	<tr>
		<td style="border-style: solid;border-width: 1px;text-align: center; height: 39px; font-size: 14pt;" colspan="2">
		<table style="width: 100%">
			<tr>
				<td style="width: 75px; height: 24px; font-family: 'Times New Roman', Times, serif; color: #0D9771;">Your Link:</td>
				<td style="height: 24px; width: 314px">
					<input name="url" type="text" style="height: 26px; width: 295px; margin-left: 0px;">
				</td>
				<td style="height: 24px; width: 83px">
					<input checked="true" name="place" type="radio" id="DI" value="DI"><label for="DI">Direct</label></td>
				<td rowspan="2">
		<input name="Submit" style="width: 118px; height: 63px; font-size: 30pt; font-family: 'Times New Roman', Times, serif; color: #19B024;" type="submit" value="Add"></td>
			</tr>
			<tr>
				<td style="width: 75px; font-family: 'Times New Roman', Times, serif; color: #0D9771;">Link Text:</td>
				<td style="width: 314px">
					<input name="txt" type="text" style="height: 26px; width: 295px; margin-left: 0px;"></td>
				<td style="width: 83px"><input name="place" type="radio" id="IF" value="IF"><label for="IF">IFrame</label></td>
			</tr>
		</table>
		</td>
	</tr>
</table>
</form>
<div style="text-align: center">
<font face="Tahoma"><a target="_blank" href="http://www.phpfreecode.com/">
<span style="font-size: 8pt; text-decoration: none">PHP Free Code</span></a></font>
</div><a target='_blank' href='https://www.phpfreecode.com' style='font-size: 8pt; text-decoration: none'>Php Best Codes</a>                                                
                                            

Example:


About @m_k_amin

This user is pending a biography.

M

Comments


Here you can leave us commments. Let us know what you think about this code tutorial!

0 / 300

TRENDING POST
1
2
3
4
5
VISITORS
Online Users: 12
Recent Members: grkkid, Manaakividuinfo.com, karticksv, sava, tinatina
advertisement 2