|
Posted by Geoffrey on 10/27/06 22:22
Hello --
I'm a little confused as to what the specific problem is. Is it that
you cannot write to the file at all, or that when you do write to the
file, all you see is a bunch of colons?
The one thing that does stand out as problematic about the code is
that, as written, the variable $pwf will always evaluate as "true." So
the username and password could be blank, and the script would still
write to the .htpasswd file.
Perhaps a more detailed explanation of the problem would help us to get
you on the right track.... :)
Geoffrey
PeacePipe wrote:
> Oops must change nick. I see there is another "Happy" already in here.
>
> Hello folks. My colleague and I are unable to figure out what is wrong
> with some code. We can't make it do what we want. Perhaps some kind
> person can help please.
>
> I run a particular pay-to-view web site. For credit card processing, we
> signed on with PayPal.
>
> The process is generally working ok. An interested person clicks the
> "join" button on the site and is transported to PayPal where he enters
> his card data and so on.
>
> PayPal generates access codes for the new member and emails them to
> him. PayPal also sends us an email announcing a new join.
>
> The problem is that, so far, I must update the .htpasswd file manually
> to liven up access to the member area.
>
> My colleague has good PHP skills and has written code to try to enable
> PayPal to update the file automatically but all attempts fail so far.
> The relevant section of the code is reproduced below. (This is not the
> entire file, only the reelvant lines.)
>
> We have proper permissions to write to the .htaccess file (777)
>
> ===============
>
> <?php
>
> $username = $_POST['username'];
> $password = $_POST['password'];
>
> $filename = '.htpasswd';
>
> $pass = crypt($password, substr($password, 0, 2));
>
> $pwf = $username.":".$pass;
>
> if ($pwf) {
>
> $fp = fopen($filename, 'a');
> $pwf = $pwf."\n";
> fputs($fp, $pwf, strlen($pwf));
> fclose($fp);
>
> $fp = fopen($filename, 'r');
> fpassthru($fp);
>
> }
>
> ?>
Navigation:
[Reply to this message]
|