Gossamer Forum
Home : Products : DBMan : Customization :

Custom Add_Form URL

Quote Reply
Custom Add_Form URL
Hi. I'm trying to build a DBMan db for my son's Cub Scout den and I'm having a little difficulty. It's probably really simple, but...

Each boy needs to enter information in the db, but has no need of viewing/searching (I'll be printing results for them later). The db is for a group of young boys who aren't entirely computer literate, so I'm trying to make it as easy as possible. To do that, I want to put links on a standard HTML page for each boy. The boy clicks the link and is taken directly to the add_form where he inputs his data.

That's all well and good. I know how to pass the UID on the URL. The problem comes in because I need each link to pass the contents of another field, "Cub_Project", the specific assignment given to each boy.

The result should be that I have list of links on an HTML page. One boy clicks the link with his name, then gets taken to the form with his user name and project name already filled in.

I've searched this board and seen other examples of passing field contents on the URL for View_Results, but not for Add_Form. When I tried the same syntax it didn't work.

I'm not too concerned about security, so if I have to disable or change something in the authorization scheme that's fine.

Can you help? How do I specify the contents of one or more fields on the URL/command line?

Thanks so much,


------------------
Sandra McClusky
Quote Reply
Re: Custom Add_Form URL In reply to
This is gonna be kinda tough. In order to be able to assign a record to a user, the user must first log in. It's not difficult to create a link that would log the child in automatically, but I'm not sure about going to the add form.

Hmmmmmmmmmm. I have an idea.

Create your link as follows:

<a href="http://.../db.cgi?db=default&userid=boy's userid&pw=boy's password&login=1&Cub_Project=boy's project">

This will take the user directly to sub html_home.

You then want the boy to be taken either to the add form (if he doesn't already have a record) or to the modify form (if he does). Yes?

You will need to have the $db_key set to the Userid field.

In sub html_home, right at the beginning, add

Code:
unless ($per_admin) {
my (%rec) = &get_record($db_userid);
if (!%rec) {
&html_add_form;
return;
}
else {
$in{'modify'} = $db_userid;
&html_modify_form_record;
return;
}
}

This will allow you, as admin, to perform all the functions, but will send the boy to the add form if there isn't a record assigned to him and to the modify form if there is.

Now to get your Cub_Project field filled in.

In sub html_add_form, right at the beginning, add

Code:
%rec=&get_defaults;
$rec{'Cub_Project'} = $in{'Cub_Project'};

change

&html_record_form (&get_defaults);

to

&html_record_form (%rec);

I think that should do it. I'm pretty sure I found all my syntax errors, but I won't guarantee a thing! Smile





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





Quote Reply
Re: Custom Add_Form URL In reply to
JPD:

Thanks for the fast response! Unfortunately it isn't exactly what I need. I wasn't clear enough in my first post, and I apologize.

The Cub_Project field can't be unique. Each boy would enter multiple posts of data on various days. For example:

-----------------------------------
Jamie
Mold Experiment
30 July 1999
Today my mold experiment grew out of the dish in the fridge to cover an orange next to the dish.

-----------------------------------
Jamie
Mold Experiment
31 July 1999
Today my mold experiment grew out of the fridge and ate my yucky brother's teddy bear.
(grin)
-----------------------------------

The projects the boys are doing require them to take notes, compile data, etc. as time goes on. Rather than deal with reams of handwritten paper of various sizes and colors, and to help them get used to using the computer, I'm setting up the db. It will be kind of a journal of each boy's project/experiment. But I don't want to have a single record that lists all the days' entries because the child might accidentally delete something or change something from a previous day. So I need to have a Cub_Project field in each record across multiple records.

Is there maybe a way that DBman can read the uid and match it to a Cub_Project name? I mean, if uid=Jamie, can DBman then automatically enter Mold Experiment into Cub_Project? If so, I would REALLY prefer to have this done through an external file like default.pass does for passwords rather than an If Then Else list inside a subroutine.

I'm pretty new at this. After a couple of weeks playing with these scripts I can understand most of what's going on, but I really couldn't write a sub routine on my own. I wouldn't know the language or where to begin. I also don't know if what I'm trying to do is even possible.

Now that I've made my problem even more odd, any ideas?

------------------
Sandra McClusky
Quote Reply
Re: Custom Add_Form URL In reply to
Each would be a new record.

Maybe I'm misunderstanding what you wrote previously.

<a href="http://.../db.cgi?db=default&userid=boy's userid&pw=boy's password&login=1&Cub_Project=boy's project">

The way I understood it, you suggested a method where the boy clicks a URL as above, and the db searches for "boy's project" in the Cub_Project field. If "boy's project" isn't already an entry in Cub_Project and tied to the UID, then up pops the Add_Form. If it DOES already exist, then the record is loaded into Modify_Record. Thus there would only be one instance of "boy's project" per user name, right?

The db can't have more than one instance of "boy's project" under the same user name, as I understood your explanation.

Thanks,

------------------
Sandra McClusky
Quote Reply
Re: Custom Add_Form URL In reply to
Not exactly. The way I had originally set it up, there would be only one record per boy. But you don't want that.

Would they be able to modify their records? If not, you can send them directly to an add form when they log on.


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





Quote Reply
Re: Custom Add_Form URL In reply to
I think I'm going to need more detail about what you want, then. Are each of the entries a new record or would the scout be adding to a text field with each new update on his progress?

The Cub_Project field doesn't have to be unique in what I gave you. Only the userid.

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





Quote Reply
Re: Custom Add_Form URL In reply to
Yes. I would like modify to remain available.

------------------
Sandra McClusky
Quote Reply
Re: Custom Add_Form URL In reply to
I think I need to start over from the beginning again, then.

This is what I thought you wanted at first: You would have a link on a webpage for each scout, which would include his username, password and project. He would click on the link and the script would check to see if he already had a record. If he did not, he would be sent to the add form and his project would be entered into the correct field. If he did already have a record, he would be taken to the modify screen, assuming that he would want to modify his record. This would assume one record per scout.

But that's not what you want, or so it seems.

Do you want one record per scout?
One record per scout/project combination?
Multiple records per scout/project combination?

If you want either of the first two, I can still do things automatically. If you want the last one, I can give you the code to automatically take the scout to the add form every time he logs in, but he would have to click a link in order to modify a previous record.


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





Quote Reply
Re: Custom Add_Form URL In reply to
JPD:

"Multiple records per scout/project combination?

"If you want either of the first two, I can still do things automatically. If you want the last one, I can give you the code to automatically take the scout to the add form every time he logs in, but he would have to click a link in order to modify a previous record."

That's exactly what I'm looking for. If you could give me that code I would really appreciate it.

One more question? Is there a way I can change the "Modify" link to be an automatic search?

As of now DBman does this: A user clicks the "modify" link and is taken to html_modify_search where he inputs search criteria; the database then returns all matching records in html_modify_form.

Is there a way that I can bypass the html_modify_search screen and go directly to the html_modify_form list? I was thinking that if I change the "modify" link to read something like:
"http://.../db.cgi?db=default&userid=boy's userid&pw=boy's password&owner=$userid&modify_form=Submit".

In other words, writing a url that the database automatically and dynamically modifies on the fly to include the current userid (above in the "owner" field), then passes that as the sole search criteria to html_modify_search transparently, then returning html_modify_form, without the user ever seeing html_modify_search. Is that possible?

Given that the majority of the database users are children and that there will be relatively few records (perhaps a dozen per child) I want to make it as simple as possible. Adding a link that shows all the records assigned to one child/userid, and only those records, already in html_modify_form would be a big help.

Thanks so much for your patience.

------------------
Sandra McClusky
Quote Reply
Re: Custom Add_Form URL In reply to
One more clarification before I give you the code.

Here's sorta how I see what you want now. On your html page, you would have something like this:

Code:
John:
Add entry for mold project
Add entry for tracking project
Add entry for cooking project
Change a previous entry
Paul:
Add entry for tracking project
Add entry for knot-tying project
Change a previous entry
George:
Add entry for mold project
Add entry for knot-tying project
Change a previous entry

Each of the above would have a link that would log the user on to the database and either take them to an "add" form or to the "modify" list that applies to them. Yes?


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





Quote Reply
Re: Custom Add_Form URL In reply to
Yes and no. It should always take them to the Add form. They're only access to the Modify form (which, again, I'd like as a link straight to the list of records in html_modify_form rather than to html_modify_search which then results in a html_modify_form list) would be through a standard link in the footer.

Does that make sense?

------------------
Sandra McClusky
Quote Reply
Re: Custom Add_Form URL In reply to
Okay. I think I can do this. Smile

Set up your links like this:

<a href="http://.../db.cgi?db=default&userid=boy's userid&pw=boy's password&login=1&Cub_Project=boy's project&add=1">

In sub html_home, right at the beginning, add

Code:
if ($in{'add'}) {
&html_add_form;
return;
}

In sub html_add_form, right at the beginning, add

Code:
%rec=&get_defaults;
$rec{'Cub_Project'} = $in{'Cub_Project'};

and change

change

&html_record_form (&get_defaults);

to

&html_record_form (%rec);

(This is code I gave you before, but I thought I'd keep everything together.)

In sub html_footer, change the middle part of the subroutine to

Code:
print qq!<P align=center><$font>!;
print qq!| <A HREF="$db_script_link_url">Home</A> !;
if ($per_admin) {
print qq!| <A HREF="$db_script_link_url&add_form=1">Add</A> !;
print qq!| <A HREF="$db_script_link_url&view_search=1">View</A> !;
print qq!| <A HREF="$db_script_link_url&delete_search=1">Delete</A> !;
print qq!| <A HREF="$db_script_link_url&modify_search=1">Modify</A> !;
print qq!| <A HREF="$db_script_link_url&view_records=1&$db_key=*">List All</A> !;
print qq!| <A HREF="$db_script_link_url&admin_display=1">Admin</A> !;
}
else {
print qq!| <A HREF="$db_script_link_url&Userid=$db_userid&delete_form=1">Delete</A> ! if ($per_del);
print qq!| <A HREF="$db_script_link_url&Userid=$db_userid&modify_form=1">Modify</A> ! if ($per_mod);
}
print qq!| <A HREF="$db_script_link_url&logoff=1">Log Off</A> |!;
print qq!</font></p>!;

You did say that the users wouldn't be doing any viewing of other records, right?

Will they be allowed to log on just to modify a record, without adding?


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





Quote Reply
Re: Custom Add_Form URL In reply to
JPD:

Yayy! It works! Thank you!

The way I understand your instructions above, the URL is the key, right? By putting "add=1" the db sends the user straight to the add_form. But if a standard URL is given, without user name or password or a specific form, the boy will be presented with the usual login screen followed by the standard login success screen, right? Then, on the login success screen I can place a footer that contains links to modify, logoff (maybe), add, and so forth.

Is that right?

> You did say that the users wouldn't be doing any viewing of other records, right?

I'd like them to be able to view their own records in the html_modify_form. In other words bypassing the html_modify_search sub to go straight to html_modify_form showing a list of all records assigned to the username. Is that possible?

> Will they be allowed to log on just to modify a record, without adding?

I'd like the features to be available for modifying and normal login (if possible) so that in the future, as the boys get used to the db, they can do more "advanced" tasks. Modifying should be as above if possible.

thanks for all your help.

------------------
Sandra McClusky

[This message has been edited by Sandra (edited August 01, 1999).]
Quote Reply
Re: Custom Add_Form URL In reply to
You got it! Smile

If you change the code in sub html_footer, it will do exactly what you want as far as giving them their own records when they click on "Modify."

In the code I gave you for sub html_footer, I set it up so that the "Add" link only shows up for admin. That's to avoid confusion when they are adding -- I got confused when I first started with DBMan, not knowing if I was supposed to click the button or the link. I'm not sure if you're going to want to keep it that way, though.



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





Quote Reply
Re: Custom Add_Form URL In reply to
I hate to bother you again but...

The Cub_Project field is written just fine into the record_form, but it isn't written into the .db file or shown on the html_add_success.

This is the setting in the .CFG:
Cub_Project => [3, 'alpha', 15, 255, 0, '', ''],

Am I missing something?

And one more question...?

"If you change the code in sub html_footer, it will do exactly what you want as far as giving them their own records when they click on "Modify."

Uhm... Could you give me an example?

Thanks again.

------------------
Sandra McClusky
Quote Reply
Re: Custom Add_Form URL In reply to
This is very odd. You do have an input field for 'Cub_Project' don't you?

Regarding the "Modify" link, if you replace the code in sub html_footer with the code I gave you in my 2:54 post -- the long one -- then, when the scout clicks "Modify" he will get a list of his records. Give it a try. Smile

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





Quote Reply
Re: Custom Add_Form URL In reply to
I copied your html_footer code and pasted it exactly. When I try clicking the "modify" link the db returns "error: no search terms specified".

------------------
Sandra McClusky
Quote Reply
Re: Custom Add_Form URL In reply to
I meant to say this when I gave you the code first and forgot. See in my code where there is the bold Userid? Change that to the name of the field that holds the userid.


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





Quote Reply
Re: Custom Add_Form URL In reply to
Sorry to interrupt. I am trying to do a similar customization on my site...I have copied the following codes from this thread:

Code:
unless ($per_admin) {
%rec=&get_record($db_userid);
unless (%rec) {
&html_add_form;
return;
}
else {
$in{'modify'} = $db_userid;
&html_modify_form_record;
return;
}
}

and pasted them into the top of the html_home sub-routine.

The problem is that the "default" user does not access the Main Menu (html_home), but is taken to the Add Record form, which should only be accessible by registered users and administrator.

I have the following authorization settings:

Code:
$auth_allow_default = 1;
@auth_default_permissions = (1,0,0,0,0);
$auth_signup = 1;
@auth_signup_permissions = (0,1,1,1,0);
$auth_modify_own = 1,0,0,0;
$auth_view_own = 1;

Am I missing something here??

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: Custom Add_Form URL In reply to
Aha! It works now!

The text size in my browser is set to medium, which doesn't show bold on type as small as the code samples. I couldn't see the bold until I increased the font display size. Had I seen bold before I would have noticed the two instances and asked about them.

Okay, back to the Cub_Project field. Nope. Nevermind. I got it. Missed a semi-colon.

It works beautifully, JP! Thanks so much!


------------------
Sandra McClusky
Quote Reply
Re: Custom Add_Form URL In reply to
Glad you got it to work, Sandra. Smile

Eliot, try

Code:
unless (($per_admin) or ($db_userid eq "default) ) {
%rec=&get_record($db_userid);
unless (%rec) {
&html_add_form;
return;
}
else {
$in{'modify'} = $db_userid;
&html_modify_form_record;
return;
}
}


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





Quote Reply
Re: Custom Add_Form URL In reply to
JPDeni,

It works great! Thanks. The only minor glitch is that the "Main Menu" link takes registered users to the "Add Record" form rather than the "Main Menu"...so what I did was hard code the URL for the default user and renamed the link to Career Connection Home. Of course, this is a quick and dirty solution since when a registered user does link on the "...Home" link, they lose their permission links,"Post Ad", "Modify Ad", "Delete Ad"....not very seamless, but it will do for the time being.

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us

[This message has been edited by Eliot (edited August 01, 1999).]