You Are Here: Home »   Code Tuesday January 6th 2009

Code Library - php

Link Validator - (1297 views)


<?

function checklink($link)
{
//see if we have a link to check
if($link)
{
//open the url
$file = @fopen ("$link""r");
                    }
                    if(
$file)
                    {         return 
true ;
                        
fclose($file);
                    }
                        }
if(
$link !="")
{
//show result if good
if((checklink($link))=="true")
{
  echo 
"<center><b>Good Link :)</b><br>($link)</center>";
}
else
{
//show result if bad
  
echo "<center><b>Bad Link :(</b><br>($link)</center>" ;
    }
}
?>
</head>
<body>
<form action="checklink.php" method="post">
<table border="0" align="center">
<tr><td>
<font size="1" face="verdana">
Input Link e.g (http://blah.com)
</font>
</td>
</tr>
<tr>
<td>
<input type=text name=link size="30" >
</td></tr>
<tr><td>
<input type="submit" value="Check Link">&nbsp;&nbsp;<input type="reset" value="Reset">
</td></tr>
</table>
</font>
</body>
</html>