views:

25

answers:

2

Dear all

exec() is new to me and i am trying to learn on how to use it to edit and update usernames and passwords of visitors, if there is a tutorial website or someone can teach me on how to use it

A: 

Why are you using exec()? It'd be far simpler to use PHP's normal file I/O functions to read and write the file.

Amber
i am using exec() to edit the .htpasswd, i was informed its fast and easier, i was look for more complicated why please see this page http://stackoverflow.com/questions/3553023/how-to-search-in-a-text-file-and-then-deleting-it
Mahmoud
+3  A: 

I discourage using htaccess/htpasswd for complex password management. Instead, I recommend you build your own password management/login system. However, if you still want to use htpasswd, follow these directions:

First, make sure that you have the htpasswd.exe file in the path/current directory.

Then, modify and add this line to your program where you need it.

exec('htpasswd.exe -b passwordFile myUserame myPassword');

where passwordFile is the name of the password file
myUsername is the username you want to change and
myPassword is the new password

If you want to use dynamic input, MAKE SURE you clean the content first. Otherwise, you could open up security holes to malicious attackers.

Kranu
if you dont recommended then what do you recommend, i have tryed mod_auth_mysql and i found out the server that i host on doent allow this mod to be enable, so the only choice i have is either to do it manually which is my searching for the username and password and delete it and add the new one, or use `exec()` if you have a better solution tell me i well be glad to take comments
Mahmoud
My recommendation is to make your own custom login system. For example, when you login to stack overflow, you don't go through one of those htpassword prompts. Instead, you go through a custom built form.If you want a tutorial on how to make your own custom login system, I think that http://www.knowledgesutra.com/forums/topic/7887-php-simple-login-tutorial/ is a pretty good one that should be easy to follow.
Kranu