What is wrong with this php code?

Peter

New member
OK I am trying to make a proigram where the user enters a url, and using fsockopen, it checks to see if the the url exists. Now with this code, it gives me the answer I want if it does exist, but if I enter a url that does not exist, it gives me a heap of errors. Any help on what I am doing wrong would be greatly appreciated.

Also is there a way to make it so that the code does not execute until the submit button is pressed? When it is pressed in this code, it is currently loading the php file it is in, where really I just want to execute the function.



Here is the code:
function isServer($domainName)
{
$errno;
$errstr;

//will return false if it does not exist
$check = fsockopen($domainName, 80, $errno, $errstr, 30);

$exist = "";

if($check == false)
{
print 'Server not responding';
}
else
{
print 'Server exists';
}

fclose($check);
}





$website = "";
print '
<form method = "GET" action="prac.php"> //document loads itself
<input type="text" name="website" size="30" value="'.$website.'" maxlength="50" /> <br />
<br />
<input type="submit" name="sendDomain" value="submit" />
</form>
';


$test = @$_GET['website'];
isServer($test);
 
Back
Top