Hi there,
I'm new to PHP. My question is the following. I wrote a script where the user needs to enter a string into a form, then the script reads from a txt file and compares it to what the user has written. the problem is, that it doesn't work properly, since, i assume, when there is more than one line in the text file, there is an invisible "code" added when reading the first line. i guess, that sounds weird, can't explain it any better. here's the script:
<?
$file=fopen("textfile.txt","r"
;
$string=fgets($file,1000);
fclose($file);
if ($string==$e_string) echo ok;
else echo bad;
?>
e_sting is the string the user entered.
in textfile.txt there would be something like:
hello
world
I'm new to PHP. My question is the following. I wrote a script where the user needs to enter a string into a form, then the script reads from a txt file and compares it to what the user has written. the problem is, that it doesn't work properly, since, i assume, when there is more than one line in the text file, there is an invisible "code" added when reading the first line. i guess, that sounds weird, can't explain it any better. here's the script:
<?
$file=fopen("textfile.txt","r"

$string=fgets($file,1000);
fclose($file);
if ($string==$e_string) echo ok;
else echo bad;
?>
e_sting is the string the user entered.
in textfile.txt there would be something like:
hello
world