|
Posted by Rik on 07/04/06 10:22
David wrote:
>>> I would like to have a members database for log ons into members
>>> areas.. How do you create and impliment such a database..
>>
>> Storing usernames and passwords
>> 1. Write table to contain member details.
>> 2. Write code to add details and ensure that username is unique
>
> I am using MySQL 5 with PHP 5. While running some test programs, I
> noticed that it is not necessary to write any code which ensures that
> a field is unique--if the field is defined as a primary key. It is
> only necessary to check the error number that is returned, if there
> was an error.
Or you can make it UNIQUE instead of primary, which would also work. I would
advise it in the database indeed. I wouldn't insert it in the database
before checking though. The point here is: it's easier to check before
trying to insert it and give a proper error-message to the client, instead
of blindly trying to insert something, get the error, provide code for the
different kinds of errors or use the very informative:'A problem has
occured'.....
Grtz,
--
Rik Wasmus
[Back to original message]
|