What I am tring to do is at the bottom, I am getting white spaces then my explode does a \n. I have tried everything I can to strip it out but can get trim to work. Here is an example of how I was tring. I made a string with a white space and trim.. No luck.. I am a real newbe so if you say add whatever() better let me know where and what format to put it in.
This was the test:
<?php
$stri = "claude ";
trim($stri);
echo "'$stri'";
?>
This is what I am tring to do.
<?php
$filename = "users.dat";
$fp = fopen($filename, "r");
$file_contents = fread($fp, filesize($filename));
fclose($fp);
// Place each line in user info file into an array
$line = explode ("\n",$file_contents);
// For as long as $i is <= the size of the $line array,
// explode each array element into a username and password pair
$i = 0;
while($i <= sizeof($line)) {
$data_pair = explode(":", $line[$i]);
if (($username == "") || ($password == "")) {
echo "you must enter a valid username and password to enter";
exit;
}else if (($username == $data_pair[0]) && ($password == $data_pair[1])) {
echo "<html><head>\n";
echo "<meta http-equiv=\"refresh\" content=\"0; URL=index.php\">\n";
echo "</head>\n";
echo "</html>\n";
$i++;
}else{
echo "Sorry, could not find your password!";
$i++;
}
}
?>