Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Name: smbotans
hi,
i have put together an seo tool online but can't get around how to verify that a url entered into the text box is valid
i tried 'file-exists' and it worked at one stage but not now
i tried:
$handle = fopen...
if (!handle) ...it works on what page but not on another
is there a way for me to check that a url points to an actual site/web page?
thanks in advance
serge
SEO Resource

hi,
what do you mean by "it works on what page but not on another"?
Because I actually use that method to test for URLs on a shoutbox
if (@fopen ($_POST['url'], "r")){
// record the url
}and I haven't found any problems (yet).

my mistake, i have so many going on in my head at the moment ... ggrr!!
i use ERROR_REPORTING(0) on 2 pages with:
$handle = fopen...
if (!handle) ...to test for valid urls
on the one page, the errors are not reported and the script reports an error when a non-valid url is entered as it should
on the other page, php reports that it cannot open a stream to the invalid url
i was wondering if:
$handle = fopen...
if (!handle) ...is the correct way to check for a valid url, if it is then i can troubleshoot why one page works while the other doesn't
thanks for your time and reply :-))
serge

ic :D
I'm also not sure whether it is the correct way or not, but my shoutbox is running for quite a long time and no problems comes up yet.
It'll return true if the URL exist (not 404) even if the URL is a redirect. To test for redirects, you can combine with $http_response_header or get_meta_data().

thanks for that
if i am using the correct function to check for a url, i will check the code to see why it works on the one page and not on the other
serge

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |