Gossamer Forum
Home : Products : DBMan : Installation :

How do I set the Userid field??

Quote Reply
How do I set the Userid field??
Hi!!

I have set up a database, where I only want the registered users to be able to add things and only be able to change and erase their own addings. My problem is that when the user adds to the database I want to set the userid in a hidden field, but how do i do that? What value should it have?

Now when a user tries to change his own stuff you get an error: no records found when you search the base for what to change.

All help appreciated.
Quote Reply
Re: How do I set the Userid field?? In reply to
For illustrative purposes, I'll call the field Userid and I'll assume it's field number 15 in your database. You'll have to change some things to fit what you have in your own database.

In the field definitions, add

Code:
Userid => [15, 'alpha', -1, 12, '', '']

In your authorization options section, set

$auth_no_authentication = 0;
$auth_modify_own = 1;
$auth_user_field = 15;

This will make the field hidden, but only if you're using the autogenerate feature. You will have to do it yourself if you create your own forms.

You might try installing my "Autosearch" mod, which is available at http://www.jpdeni.com/.../Mods/autosearch.txt . This will allow users to just click the "Modify" or "Delete" link and they'll automatically be taken to their own record(s).


------------------
JPD





Quote Reply
Re: How do I set the Userid field?? In reply to
I've got everything right, but I don't use the autoform function. How should the hidden input field for the Userid look? That's what I want to know.
Quote Reply
Re: How do I set the Userid field?? In reply to
Oh. Okay.

Near the beginning of sub html_record_form, just after

print qq|

add

<input type="hidden" name="Userid" value="$rec{'Userid'}">

Change Userid to match the name of your userid field as defined in your .cfg file.

------------------
JPD





Quote Reply
Re: How do I set the Userid field?? In reply to
I have my settings set as you've indicated but for for some reason my "userid" keeps appearing in the field below.....
and then in the field below I get an error, which is expected as I have that field set so that the entry must be in a certain format. Thanks for your help!

Here's the CFG settings..

LastName => [1, 'alpha', 40, 255, 0, '', ''],
FirstName => [2, 'alpha', 40, 255, 0, '', ''],
Title => [3, 'alpha', 40, 255, 0, '', ''],
Organization => [4, 'alpha', 40, 255, 0, '', ''],
Department => [5, 'alpha', 40, 255, 0, '', ''],
Phone => [6, 'alpha', 40, 255, 0, '212-', ''],
Fax => [7, 'alpha', 40, 255, 0, '212-', ''],
Email => [8, 'alpha', 40, 255, 0, '@', ''],
Comments => [9, 'alpha', '40x3', 255, 0, '', ''],
DBKEY => [10, 'numer', -2, 255, 0, '', ''],
USERID => [11, 'alpha', -2, 255, 0, '', ''],
UNU_Seminar_to_attend => [12, 'alpha', -2, 255, 0, '13 Feb UNU Conflict

Resolution Seminar', '13 Feb UNU Conflict Resolution Seminar'],

);

# The column name for the database key. Can be any column, but it must be unique!
# You can't have two records with the same key value!
$db_key = 'DBKEY';
# Track the key? Should DBMan keep a counter of the next key to use? This isn't
# neccessary if you can guarantee that your entry in the key field will be unique
# (i.e. a userid).
$db_key_track = 1;
# Database delimeter.
$db_delim = ',';
# Use file locking (1 = Yes, 0 = No). Should be used, but won't work on Win95.
$db_use_flock = 1;
# Auto generate the html forms (1 = Yes, 0 = No).
$db_auto_generate = 1;
# Display Benchmarking Information (1 = Yes, 0 = No).
# use Benchmark; # Uncomment this line if benchmarking is used.
$db_benchmark = 0;
# Display Debugging Information (1 = Yes, 0 = No).
$db_debug = 0;

# Select fields. Field name => 'comma seperated list of drop down options'.
%db_select_fields = (

);

# Radio fields. Field name => comma seperated list of radio buttons.
%db_radio_fields = ( );

# Checkbox fields. Field name => Checkbox value.
%db_checkbox_fields = ( );

# Default maximum number of hits returned in a search.
$db_max_hits = 10;
# Bold search results (1 = Yes, 0 = No).
$db_bold = 1;
# Regular and title fonts used in auto_generatrion and html.pl.
$font = 'font face="verdana,arial,helvetica" size="2"';
$font_title = 'font face="verdana,arial,helvetica" size="4"';

# Authorization Options
# --------------------------------------------------------
# No Authentication? (1 = "there is no authentication", 0 = "there is authentication")
# If you choose no authentication, then set the permissions of what
# people can do with: @auth_default_permissions below.
$auth_no_authentication = 0;

# The amount of time in seconds that user files are kept in the
# auth directory before the program removes them. 2-6 hours is
# probably a good value.
$auth_time = 21600; # 6 hours (in seconds)

# Enable (1) or disable (0) logging.
$auth_logging = 1;

# Allow a default user? This means you can specify a user via the URL
# and skip the logon process. Use this to allow people to search without
# logging on, but require log in if they want to add/modify/remove etc.
# (1 = "yes", 0 = "no")
$auth_allow_default = 1;

# Default permissions used if there is no authentication, or for a default
# user. (View, Add, Delete, Modify, Admin), 1 = enable, 0 = disable.
@auth_default_permissions = (1,1,0,0,0);

# Allow people to sign up for their own userid/passwords? They will
# recieve default permissions.
$auth_signup = 1;

# Permissions a new signup should get.
@auth_signup_permissions = (1,1,0,0,0);

# Registered users: can modify/delete _only_ own records. For this to make
# sense you should set default off or to 1,0,0,0.
$auth_modify_own = 1;

# Registered users: can view _only_ own records. For this to make sense
# you should turn off default permissions.
$auth_view_own = 1;

# Auth user field. This is the field position in the database used for storing
# the userid who owns the record. Set to -1 if not used.
$auth_user_field = 11;

# URL to send user if they chose log off. Leave blank and the script will return to
# the logon prompt (although this only makes sense if you are using authentication).
$auth_logoff = "http://www.unu.edu/ona/thanksforreg.htm";

#


Quote Reply
Re: How do I set the Userid field?? In reply to
The problem may be in the way you have the number sequence of your fields. The fields should start with 0.

Try changing your fields to:


LastName => [ 0,'alpha', 40, 255, 0, '', ''],
FirstName => [ 1,'alpha', 40, 255, 0, '', ''],
Title => [ 2,'alpha', 40, 255, 0, '', ''],
Organization => [ 3,'alpha', 40, 255, 0, '', ''],
Department => [ 4,'alpha', 40, 255, 0, '', ''],
Phone => [ 5, 'alpha', 40, 255, 0, '212-', ''],
Fax => [ 6, 'alpha', 40, 255, 0, '212-', ''],
Email => [ 7, 'alpha', 40, 255, 0, '@', ''],
Comments => [ 8, 'alpha', '40x3', 255, 0, '', ''],
DBKEY => [ 9, 'numer', -2, 255, 0, '', ''],
USERID => [10, 'alpha', -2, 255, 0, '', ''],
UNU_Seminar_to_attend => [11, 'alpha', -2, 255, 0, '13 Feb UNU Conflict Resolution Seminar', '13 Feb UNU Conflict Resolution Seminar'],

Hope this helps

Unoffical DBMan FAQ
http://webmagic.hypermart.net/dbman/