deep
08-25-2003, 12:32 PM
I feel like exploading when a simple code like this fu*ks up... Im compering 2 variables here and in this case the if - statement never goes true... (the one I marked below)
WHY?
The $var variable is located on another page as a textfield and sent here through the form after the user press submit.
This script is seposed to extract a word on the forst line in one file and compare it with another given thriugh a form submit (textfield).
<?php
if (file_exists("word.txt")) {
if (!$fp = fopen("word.txt", "r")) { echo "Error!"; }
$fil_pass = fgets($fp, 15);
fclose($fp);
#
if ($var == ""){
echo "You didnt enter a word!";
#
} elseif ($var == $fil_pass) {
echo "words match!!"; # THE WORDS MATCH BUT STILL I GET "Words did not match!"!!????
#
} else {
echo "Words did not match!";
}
#
} else {
echo "The file words.txt does not exist!";
}
?>
WHY?
The $var variable is located on another page as a textfield and sent here through the form after the user press submit.
This script is seposed to extract a word on the forst line in one file and compare it with another given thriugh a form submit (textfield).
<?php
if (file_exists("word.txt")) {
if (!$fp = fopen("word.txt", "r")) { echo "Error!"; }
$fil_pass = fgets($fp, 15);
fclose($fp);
#
if ($var == ""){
echo "You didnt enter a word!";
#
} elseif ($var == $fil_pass) {
echo "words match!!"; # THE WORDS MATCH BUT STILL I GET "Words did not match!"!!????
#
} else {
echo "Words did not match!";
}
#
} else {
echo "The file words.txt does not exist!";
}
?>