Jump to content

Wrong?


unidox

Recommended Posts

I have this code:

 

$url = "site.com?key=" . SITE_LIC . "&ref=" . $_SERVER["HTTP_REFERER"] . "";
$lic = fopen($url, "r");
$lic = fgets($lic, 4096);

if ($lic == 1) {
echo "Verified";
} else {
echo "Suspended";
}

 

If I echo $lic it says 1, but if I use the if statement, it keeps saying suspended. Whats wrong?

Link to comment
https://forums.phpfreaks.com/topic/100728-wrong/
Share on other sites

Oh my god that is scary. Why are you using a constant?

 

fgets returns a STRING, not a boolean value.

 

You want this:

 

$url = "site.com?key=" . SITE_LIC . "&ref=" . $_SERVER["HTTP_REFERER"] . "";
$lic_h = fopen($url, "r");
$lic = fgets($lic_h, 4096);

if ($lic === FALSE) {
header("Location: http://www.site.com/index.php?p=lic_invalid");
exit();
}

Link to comment
https://forums.phpfreaks.com/topic/100728-wrong/#findComment-515211
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.