Valid URL and then ?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
katerina
Forum Newbie
Posts: 11
Joined: Wed May 14, 2008 1:41 pm

Valid URL and then ?

Post by katerina »

Hi,
Could anyone help me with my homework ?

I have found this code :

Code: Select all

 
<?php
 
if ($_REQUEST[url] != "") {
    $result = 1;
    if (! ereg("^https?://",$_REQUEST[url])) {
        $status = "This demo requires a fully qualified http:// URL";
    } else {
        if (@fopen($_REQUEST[url],"r")) {
            $status = "This URL is readable";
        } else {
            $status = "This URL is not readable";
        }
    }
} else {
    $result = 0;
    $status = "no URL entered (yet)";
}
 
?>
<html><head><title>Does a URL exist?</title></head>
<body bgcolor="white"><table width="600"><tr><td>
 
 
<?php
if ($result != 0) {
   print "Checking URL <b>".htmlspecialchars($_REQUEST[url])."</b><br />";
}
print "$status";
?>
<br />
<hr />
Please enter a URL you would like to validate (existance check):
<form>The URL: <input name="url" size=50/>
and <input type="submit" /></form>
<hr />
Copyright <a href="http://www.wellho.net/">Well House Consultants</a>
<?= date("Y") ?><br /><br />
<b>Source code of this example:</b><br /><br />
<?= highlight_file($_SERVER[SCRIPT_FILENAME],1) ?>
</td></tr></table>
</body></html>
When an user clicks on submit and if the url is valid , I would like to disappear the previous form and appear a button "NEXT" which onclick going to an other page.

Pleaseeeeeeeeee help me. It's important !
Thank you !
katerina
Forum Newbie
Posts: 11
Joined: Wed May 14, 2008 1:41 pm

Re: Valid URL and then ?

Post by katerina »

Somebody ?
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Re: Valid URL and then ?

Post by aceconcepts »

You will need an "indicator" to use in order to determine whether or not to show the "NEXT" button:

Code: Select all

 
$urlStatus=0;   //INSERT THIS
 
if ($_REQUEST[url] != "") {
    $result = 1;
    if (! ereg("^https?://",$_REQUEST[url])) {
        $status = "This demo requires a fully qualified http:// URL";
    } else {
        if (@fopen($_REQUEST[url],"r")) {
 
            $urlStatus=1;   //INSERT THIS
 
            $status = "This URL is readable";
        } else {
            $status = "This URL is not readable";
        }
    }
} else {
    $result = 0;
    $status = "no URL entered (yet)";
}
 
And where you want to display your "NEXT" button simply check the value of $urlStatus

Code: Select all

 
if($urlStatus==1)
{
   //put next button here
}
 
Post Reply