[PHP-DB] Re: Encrypting DB content

2005-12-31 Thread Richard Dyce

On 31 Dec 2005, at 04:15, Chris Payne [EMAIL PROTECTED] wrote:

I am about to launch the website for my complex where the  
homeowners can
login and check their billing status etc .. what is the best way,  
with PHP

and MySQL, to store an ENCRYPTED password into the database so that if
someone got into the DB they couldn't read the password but if they  
enter it

into the form on the site it still works?


The trick is not to store a plain password in the db, but an  
encrypted one. When

you store the password in the user record use something like

  mysql insert into users (username, password) values ('dd',  
old_password('1234'));


That gets you...

  mysql select * from users
  +--+--+
  | username | password |
  +--+--+
  |   dd | 446a12100c856ce9 |
  +--+--+
  1 row in set (0.24 sec)


Then to check if a user is valid, you just have to do a search to  
check validity:


  mysql  select * from users where username = 'dd' and password =  
old_password('1234');


This does require you to have a password replacement page - which  
means emailing them a new one (as you can't recover the old one from  
the db).


Hope that's some help,

R

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] mysqldump and OS X

2005-05-10 Thread Richard Dyce
Wonder if anyone out there can help?
I'm trying to execute a mysql dump on my local Mac (running 10.4),  
and I'm running into an odd problem, possibly something to do with  
permissions or $PATH setup.

Here's the code...
?php
  $dbhost = 'localhost';
  $dbuser = 'user';
  $dbpass = 'blah';
  $dbname = 'property_rental';
  $filepath = $HTTP_SERVER_VARS['DOCUMENT_ROOT'];
  $filename = $filepath/data.sql;
  passthru(mysqldump --opt -h$dbhost -u$dbuser -p$dbpass $dbname  
$filename);

?
Now, if I execute this on the remote server, with the correct login  
details, it all works tickety-boo. If I execute it locally on my Mac  
using the built-in Apache server and a localhost address. But if I  
change the passthru call to an echo, and then copy and past the  
result into the terminal app, it works. What am I doing wrong? Any  
ideas greatfully received.

R
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] mysqldump and OS X

2005-05-10 Thread Richard Dyce
On 10 May 2005, at 07:24, Constantin Brinzoi wrote:
maybe you have to specify the full path to mysqldump like:
passthru(/path/to/mysqldump --opt -h$dbhost -u$dbuser -p$dbpass  
$dbname
It was worth a try - but no, changing the exec line to:
exec(/usr/local/mysql-standard-4.1.7-apple-darwin7.5.0-powerpc/bin/ 
mysqldump --opt -h$dbhost -u$dbuser -p$dbpass $dbname $filename);

Doesn't seem to make any difference :-(
Thanks anyway.
R