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!
Im making a very simple register program for VB where there is a webbrowser where you enter you're serial number. The program then reads when you've got to the success page (in this case http://www.google.com) then the program accepts you. I want to make it read a file (for example: http://me.myhost.com/key.txt and compare $serial to the contents. How could I do that?
<?php
$serial = $_GET["serial"];
// get contents of a file into a string
$filename = "http://me.myhost.com/key.txt";
$handle = fopen( $filename, "rb");
while( !feof( $handle )){
$line = fgets( $handle ); //read line by line
if($serial==$line){
return(true); //if serial matches with line, return true
fclose($handle); //close the file
}
}
return(false);
?>
Warning: fopen(): URL file-access is disabled in the server configuration in /home/freehost/t35.com/j/u/juniorfiles/reg.php on line 6
Warning: fopen(http://cardiffhigh.cardiff.sch.uk/~jamie.sargant/key.txt): failed to open stream: no suitable wrapper could be found in /home/freehost/t35.com/j/u/juniorfiles/reg.php on line 6
Warning: feof(): supplied argument is not a valid stream resource in /home/freehost/t35.com/j/u/juniorfiles/reg.php on line 7
Warning: fgets(): supplied argument is not a valid stream resource in /home/freehost/t35.com/j/u/juniorfiles/reg.php on line 8
Then the last two just loop and keep giving them again.
The file will only have one bit of text in (the entire contents may be "1234-5678-9101"). I just need the php to compare the user entered string entirely to the contents of that file.
I don't know if there is any advantage or disadvantage in doing it this way,
but I will look better.
And you can have access to all the serials later in the Script if you need them.