[PHP]URL Verification
#1
Posted 07 August 2005 - 03:19 PM
Written By Ben Kippax ::: http://www.layouts4u.co.uk :::
This tutorial will show you how to verify if a URL exists or if its a 404 error.
Step 1
<p><form action="verify.php" method="get">
URl (Don't include http://) <input type="text" name="url"><br/>
<input type="submit" value="send"><br/>
</form></p>
call this file "form_verify.php"
Step 2
<?
$up = @fsockopen("$url", 80, $errno, $errstr, 30);
if($up)
{
echo "$url Can Be found";
}
else
{
echo "<b>Oops! <br>$url Cant Be Found</b>";
}
?>
Call This file "verify.php"
Now, all you have to do is include form_verify.php in a page or keep it as a stand alone script and just link it. It's as simple as that.
For a working example please go to http://www.sephet.co...form_verify.php
I Hope you enjoy the tutorial.
Regards,
Ben
#2
Posted 07 August 2005 - 10:10 PM
#3
Posted 07 August 2005 - 10:22 PM
Replace Step 2 with thiscan there be a way to check if they input the http:// part? just to make sure your visitors read directions...
<? $url = $_POST['url']; //REMOVE HTTP $url = str_replace('http://', '', $_POST['url']); $up = @fsockopen("$url", 80, $errno, $errstr, 30); if($up) { echo "$url Can Be found"; } else { echo "<b>Oops! <br>$url Cant Be Found</b>"; } ?>
Just in case a host has disabled REGISTER_GLOBALS, step two should originally be this:
<? //DEFINE $URL $url = $_POST['url']; //GET RID OF THE HTTP $url = str_replace('http://', '', $_POST['url']); //TEST URL $up = @fsockopen("$url", 80, $errno, $errstr, 30); //IF URL FOUND if($up) { echo "$url Can Be found"; } //IF 404 else { //ECHO RESULTS echo "<b>Oops! <br>$url Cant Be Found</b>"; } ?>
Edited by Jaymz, 07 August 2005 - 10:25 PM.
#4
Posted 08 August 2005 - 04:24 PM
#5
Posted 08 August 2005 - 05:06 PM
$url = $_POST['url']; $url = str_replace('http://', '', $_POST['url']);
that should be the first two lines of the code.
Really this is just saying that if the url contains http:// reaplace it with "nothing".
#6
Posted 08 August 2005 - 06:11 PM
<?php $search = "(http):\/\/(.*?)"; if (eregi($search, $_POST['url'])) { //success } else { die('You did not enter http:// at the beginning of your url'); } ?>The way sephet described all you would have to do is put http:// anywhere in the string, like www.google.com/http://
Would result www.google.com/
#7
Posted 08 August 2005 - 07:40 PM
#8
Posted 08 August 2005 - 07:46 PM
#9
Posted 08 August 2005 - 07:56 PM
The way I posted would quietly get rid of the http:// if it existed, or continue on it's merry wayI don't think that's what he wanted to do though, You could just have it disable the use of some extensions..Or display < and > so they can't use XSS, plus I messed up on my script up there, pm me and I'll give you one that works
#10
Posted 09 August 2005 - 02:04 AM
EDIT: my bad he does want to get rid of it, sorry jaymz
Edited by HaloprO, 09 August 2005 - 02:09 AM.
#11
Posted 09 August 2005 - 09:32 AM
Edited by brent, 09 August 2005 - 09:32 AM.
#12
Posted 09 August 2005 - 10:07 AM
#13
Posted 09 August 2005 - 10:55 AM
#14
Posted 11 March 2006 - 04:11 PM
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users