Gossamer Forum
Home : Products : DBMan : Customization :

Posting data to the user.db via admin screen

Quote Reply
Posting data to the user.db via admin screen
First, thanks to JPDeni, with her tutorial I could able to build a relational database and It works well nearly as I need.

On the other hand I need to make a last modification. In my database, there is one admin and many users who can deal with their records only. All the field and file names are same to the relational db tutorial at this stage.

So is it possible to add the "New User Name" (in the admin screen where the admin gives user names and passwords and permissions for the new users) as the UserID automatically to the "user.db"?

Best regards,

akula
Quote Reply
Re: [akula] Posting data to the user.db via admin screen In reply to
Quote:
So is it possible to add the "New User Name"...

Just about anything is possible. The question is whether it's easy or not. :-)

First, we need to know which fields you want to be added to the user.db file. If you're adding more than the username, you'll need to add input fields to sub html_admin_display in the html.pl file. If you add any fields, make sure the input fields have the same names as the fields that are defined for the user.db file.

The actual adding of the records would go into sub admin_display in the db.cgi file, in the section that starts with "$in{'new_username'} and do {". Assuming you're using the structure I suggested in the relational.txt file, after

close PASS;

add

Code:
&switch_to_user;
open (DB, ">>$db_file_name") or &cgierr("error in admin_display. unable to open database: $db_file_name.\nReason: $!");
if ($db_use_flock) {
flock(DB, 2) or &cgierr("unable to get exclusive lock on $db_file_name.\nReason: $!");
}
print DB &join_encode(%in);
close DB; # automatically removes file lock

This does not do any error checking at all. It's up to the admin to be sure that there isn't already a user with that name.


JPD
----------------------------------------------------
JPDeni's DBMan-ual
How to ask questions the smart way.
Quote Reply
Re: [JPDeni] Posting data to the user.db via admin screen In reply to
Hi, I have not tried your solution yet, very busy in these days. But will try at first occasion.

Thanks,

akula