CRLF Problem writing ASCII Flat File
| From: | Bob Holden | Date: | Thu, 20 Dec 2001 10:51:41 +0000 |
| Subject: | CRLF Problem writing ASCII Flat File | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-78311@lists.php.net to get a copy of this message | ||
Using Linux 7.2/PHP 4/Apache. I'm using the following code snippet to
process the POST of a form that sends $UserID and $Password:
<?php
$CryptPassword = md5($Password); \\encrypt the password
$TheFile = "/path/.htpasswd"; \\Set the file name/path
$Data = "$UserID:$CryptPassword\n\r"; \\ Setting the data stream for
the write
$FilePointer = fopen($TheFile, "a"); \\open the file
fwrite($FilePointer, $Data); \\write the data stream
fclose ($FilePointer); \\close the file
?>
to write to .htpasswd with the following format/layout:
userid:passwd
userid:passwd
userid:passwd
userid:passwd
userid:passwd
However, the data appears in the file without the carriage return or new
lines in the file as follows:
userid:passwd userid:passwd userid:passwd userid:passwd userid:passwd
userid:passwd userid:passwd
How can I write the carriage returns to the file so that they show up via
vi or via windows notepad?
ALSO, will Apache and .htpasswd deal with md5() passwords, or do I need to
limit myself to the crypt() function?
TIA