SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Addict Phil-man's Avatar
    Join Date
    Nov 2000
    Posts
    291
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi:

    I need to write some code that will redirect a user to a particular page. I know how to do that, but there's a twist. Here's the order of things:

    1) PHP script "pings" a URL to make sure it is available
    2) If so, it will redirect to that URL
    3) If not, it will redirect to another URL

    I wasn't able to find anything about "ping" in the PHP manual. Can anyone help? Thanks!

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Doing a simple fopen should tell you whether the url is valid:

    PHP Code:
    $url "http://www.yahoo.com";
    $fp = @fopen($url"r");
    if (
    $fp) {
    fclose($fp);
    header("Location: $url");
    }
    else {
    print 
    "Sorry link is dead";

    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  3. #3
    SitePoint Addict Phil-man's Avatar
    Join Date
    Nov 2000
    Posts
    291
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, that was incredibly easy. Well, except for the fact that I had to view the Source of this page and weed through all the HTML tags to read your code... I noticed that on a few other posts that I've read today. Am I the only one having this problem?

  4. #4
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No, so you can't see the php code on the screen?
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  5. #5
    SitePoint Addict Phil-man's Avatar
    Join Date
    Nov 2000
    Posts
    291
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nope. All I see is the following:

    "Doing a simple fopen should tell you whether the url is valid:







    "

    (i.e. lots of blank space after your first sentence). Again, I noticed it on a few other posts too, but, as I said, I just viewed the source and got the information that way. It was a little tricky.

    Anyway, thanks again.

  6. #6
    SitePoint Guru DenverDave's Avatar
    Join Date
    Feb 2001
    Location
    Denver, Colorado
    Posts
    630
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code shows up on my screen fine. Do you have another browser to try?

    Dave

  7. #7
    SitePoint Addict Phil-man's Avatar
    Join Date
    Nov 2000
    Posts
    291
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I can see the code in IE 5.5 but not in Netscape 4.76. Anyone else using Netscape 4.76? I've only experienced the problem recently. I know SitePoint was redesigned not so long ago...

  8. #8
    SitePoint Guru DenverDave's Avatar
    Join Date
    Feb 2001
    Location
    Denver, Colorado
    Posts
    630
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Interesting - I can see the code in both I.E 5.5 and Netscape 3.0 (that I keep around for such things). WindowsME computer. Now if you were using AOL's Netscape 6, I would not be surprised at a problem.

    Dave


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •