Gossamer Forum
Home : Products : DBMan : Customization :

Entering Data Externally via links

(Page 1 of 2)
> >
Quote Reply
Entering Data Externally via links
Hi Everyone,

I have recently picked up a copy of DBman, installed it and am now playing around with it to try to get it to do all the hard work for me. I am very impressed with what i have discovered so far!! But i have a problem i need to be able to allow users to click on different links outside DBman and then this will enter different pieces of information into a field in the database. i.e. UK or USA. But as i am a newbie to Perl i don't have a clue how to do this.

I am using UNIX incase you need to know this inorder to help me. Any help will be gratefully recieved as i am a student intern in a large company who has no clue about this and they are all relying on me to get this to work.

Thankyou,
Elle

Quote Reply
Re: Entering Data Externally via links In reply to
First of all, in order to do this, you will have to allow default users to add records. You will not be able to require them to log in first.

Set up your link like

...db.cgi?db=database&uid=default&add_form=1&Field=value&field=value&field=value

You can have as many fields as you want, but the names *must* match your field names in your .cfg file exactly. The only exception to this is that, if you have a space in your field name, you must replace the space with a +.

So, if you had a field name called 'Home Country' you would use

&Home+Country=UK

Then, in sub html_record_form, after

my (%rec) = @_;

add

Code:
if ($in{'add_form'}) {
$rec{'field'} = $in{'field'};
}
Again, your field names must match the field names from your .cfg file exactly. This time, do not replace spaces with a +.

Add as many lines within the loop as you have fields you want to fill.

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Entering Data Externally via links In reply to
JPDeni,
Thankyou for your help it worked!! I'll probably be back with more questions later.

Elle

Quote Reply
Re: Entering Data Externally via links In reply to
Ok i'm back again with another question along the sames lines as last time. I have used
db.cgi?db=default&add_form=1&SE=Matt+Dunnigan" TARGET="_self" ALT="Supplier Input Login Screen">

as my link because i still need the user to log in, so that part works but then when i get to the main menu and select add, it loses all the information that i am passing. I have tried to put the link information in different places in html.pl but nothing worked it didn't enter the field data into the form like i requested. Perl and HTML are totally new to me so i am still trying to pick it up, but this has me confused. Please help.

Thankyou
Elle

Quote Reply
Re: Entering Data Externally via links In reply to
Right. As I said, if you use a link, you have to have allow default users to add. You cannot require a login.

There is a way around it, but only if all of your links are filling in the same field. Will all of your links be adding in the SE field?


JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Entering Data Externally via links In reply to
Yeah i have one link for each form but it will eventually need more than one field in each link but i am just trying to get one to work just now. So yes that link will only fill in that one field then the user will have to fill in the rest. Is this possible or should i rethink my method?

Thanks,
Elle

Quote Reply
Re: Entering Data Externally via links In reply to
You can do it, but you will have to make adjustments if you add more fields.

In sub html_login_form, after

<input type=hidden name="uid" value="$db_uid">

add

<input type=hidden name="SE" value="$in{'SE'}">

You will also need to add the field to sub html_login_failure.

If you're allowing users to sign up online, you'll need to add it to sub html_signup_form and html_signup_success. And, if you install the password lookup mod, you'll need to add it to sub html_lookup_form and sub html_lookup_success.

Then, at the beginning of sub html_home, add

Code:

if ($in{'SE'}) {
&html_add_form;
return;
}
You need to remember that DBMan does not remember anything from one "click" to the next. Each time you click a link or a button, the script starts over from scratch. So.... if you want it to remember anything, you have to either add it to a link or add a hidden field in a form.

If you add more fields to the links later on, you will need to add hidden fields like the one above for each of the fields -- and you'll need to add it to all of the possible subroutines a person might encounter between your static page and the add form.

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Entering Data Externally via links In reply to
Ok Thanks i tried this and it allows me to go straight from the login screen to the add form screen but when i fill in the rest of the fields normally and submit it the SE field (the one that is being passed in) remains blank. I changed it so that it could not be null in the .cfg file and it returned the error:

SE (Can not be left blank)

Elle

Quote Reply
Re: Entering Data Externally via links In reply to
I had another wee play around with it and i added

<input type=hidden name="SE" value="$in{'SE'}">

to sub html_add_form aswell and that made that part of DBman remember it, so thanks again i'm going to try and pass more fields in so i'll let you know how i get on.

Thanks for your help
Elle


Quote Reply
Re: Entering Data Externally via links In reply to
You should have the field within sub html_record_form and you should add the code that I gave you in my first response to you.



JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Entering Data Externally via links In reply to
Hi
Right, i have managed to get everything to work all my links work and the data is passing in nicely, woo hoo!! But the data that is passed in is being attached with a | on the end this is the character that i have used for the field separator, i have tried a few different things to get rid of it but nothing worked. Does anyone have any ideas?

Thanks in advance,
Elle

Quote Reply
Re: Entering Data Externally via links In reply to
Sounds like you have two fields with the same name.

If you have a field in sub html_add_form, take it out. The fields should *only* be in sub html_record_form.

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Entering Data Externally via links In reply to
Ok bear with me as i am a bit confused.

I have
my (%rec) = @_;
($db_auto_generate and print &build_html_record_form(%rec) and return);


if ($in{'add_form'}) {
$rec{'Platform'} = $in{'Platform'};
$rec{'Customer'} = $in{'Customer'};
$rec{'Commodity'} = $in{'Commodity'};

}

in sub html_record_form

And

if ($in{'Platform'}) {
&html_add_form;
return;
}

if ($in{'Customer'}) {
&html_add_form;
return;
}

if ($in{'Commodity'}) {
&html_add_form;
return;
}
in sub html_home

and
<form action="$db_script_url" method="POST">
<input type=hidden name="db" value="$db_setup">
<input type=hidden name="uid" value="$db_uid">
<input type=hidden name="Platform" value="$in{'Platform'}">
<input type=hidden name="Customer" value="$in{'Customer'}">
<input type=hidden name="Commodity" value="$in{'Commodity'}">

in html_add_form

and
<form action="$db_script_url" method="post" name="form1">
<input type=hidden name="db" value="$db_setup">
<input type=hidden name="uid" value="$db_uid">
<input type=hidden name="Platform" value="$in{'Platform'}">
<input type=hidden name="Customer" value="$in{'Customer'}">
<input type=hidden name="Commodity" value="$in{'Commodity'}">

in sub html_login_form and also in sub html_login_failure

Sorry but i can feel myself getting confused between the different terms. Which part i am meant to remove as i tried but it returned errors.

Elle

Quote Reply
Re: Entering Data Externally via links In reply to
In Reply To:
<form action="$db_script_url" method="POST">
<input type=hidden name="db" value="$db_setup">
<input type=hidden name="uid" value="$db_uid">
<input type=hidden name="Platform" value="$in{'Platform'}">
<input type=hidden name="Customer" value="$in{'Customer'}">
<input type=hidden name="Commodity" value="$in{'Commodity'}">

in html_add_form
Delete

<input type=hidden name="Platform" value="$in{'Platform'}">
<input type=hidden name="Customer" value="$in{'Customer'}">
<input type=hidden name="Commodity" value="$in{'Commodity'}">


You should have these fields also in sub html_record_form, except they should be

<input type=hidden name="Platform" value="$rec{'Platform'}">
<input type=hidden name="Customer" value="$rec{'Customer'}">
<input type=hidden name="Commodity" value="$rec{'Commodity'}">




JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Entering Data Externally via links In reply to
Hi

i'm so sorry to keep on bugging you but i tried this and it returned a server error, i tried putting it in different places within the sub html_record_form and i checked my permissions but no luck i couldn't get rid of this server error.

Elle

Quote Reply
Re: Entering Data Externally via links In reply to
I'll need to see your html.pl file.

Please copy the file to a web-accessible directoyr (one where you would place .html files) and rename it to html_pl.txt. Then let me know where I can pick it up and I'll find the error.

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Entering Data Externally via links In reply to
I'm using an internal web-server so i don't have any external web-space so i can't do that for you. Sorry, i could email it to you but that's about all.

Elle

Quote Reply
Re: Entering Data Externally via links In reply to
You can post sub html_record_form here in the forum. It's a lot easier for me to deal with than using email. Smile

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Entering Data Externally via links In reply to
Ok here goes...

sub html_record_form {
# --------------------------------------------------------
# The form fields that will be displayed each time a record is
# edited (including searching). You don't want to put the
# <FORM> and </FORM tags, merely the <INPUT> tags for each field.
# The values to be displayed are in %rec and should be incorporated
# into your form. You can use &build_select_field, &build_checkbox_field
# and &build_radio_field to generate the respective input boxes. Text and
# Textarea inputs can be inserted as is. If you turn on form auto
# generation, the program will build the forms for you (all though they may
# not be as nice). See the README for more info.


<input type=hidden name="Platform" value="$rec{'Platform'}">
<input type=hidden name="Customer" value="$rec{'Customer'}">
<input type=hidden name="Commodity" value="$rec{'Commodity'}">


my (%rec) = @_;
($db_auto_generate and print &build_html_record_form(%rec) and return);


if ($in{'add_form'}) {
$rec{'Platform'} = $in{'Platform'};
$rec{'Customer'} = $in{'Customer'};
$rec{'Commodity'} = $in{'Commodity'};

}



my $font_color = 'Font face="Verdana, Arial, Helvetica" Size=3 Color=#003399';

print qq|
<TABLE WIDTH="450" CELLPADDING=0 CELLSPACING=0 BORDER=1 BGCOLOR="#FFFFCC">
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="150"><$font_color>Part Number :</FONT></TD>
<TD VALIGN="TOP" WIDTH="475"> <INPUT TYPE="TEXT" NAME="Part Number " SIZE="20" VALUE="$rec{'Part Number '}" MAXLENGTH="35"></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="150"><$font_color>Supplier:</FONT></TD>
<TD VALIGN="TOP" WIDTH="475"> <INPUT TYPE="TEXT" NAME="Supplier" SIZE="20" VALUE="$rec{'Supplier'}" MAXLENGTH="255"></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="150"><$font_color>SE:</FONT></TD>
<TD VALIGN="TOP" WIDTH="475"> <INPUT TYPE="TEXT" NAME="SE" SIZE="20" VALUE="$rec{'SE'}" MAXLENGTH="255"></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="150"><$font_color>Customer:</FONT></TD>
<TD VALIGN="TOP" WIDTH="475"> |; print &build_select_field("Customer",$rec{'Customer'}); print qq|</TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="150"><$font_color>Date:</FONT></TD>
<TD VALIGN="TOP" WIDTH="475"> <INPUT TYPE="TEXT" NAME="Date" SIZE="12" VALUE="$rec{'Date'}" MAXLENGTH="25"></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="150"><$font_color>Platform:</FONT></TD>
<TD VALIGN="TOP" WIDTH="475"> <INPUT TYPE="TEXT" NAME="Platform" SIZE="20" VALUE="$rec{'Platform'}" MAXLENGTH="255"></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="150"><$font_color>Commodity:</FONT></TD>
<TD VALIGN="TOP" WIDTH="475"> <INPUT TYPE="TEXT" NAME="Commodity" SIZE="20" VALUE="$rec{'Commodity'}" MAXLENGTH="255"></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="150"><$font_color>RPM Month:</FONT></TD>
<TD VALIGN="TOP" WIDTH="475"> <INPUT TYPE="TEXT" NAME="RPM Month" SIZE="8" VALUE="$rec{'RPM Month'}" MAXLENGTH="20"></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="150"><$font_color>RPM Goal:</FONT></TD>
<TD VALIGN="TOP" WIDTH="475"> <INPUT TYPE="TEXT" NAME="RPM Goal" SIZE="8" VALUE="$rec{'RPM Goal'}" MAXLENGTH="20"></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="150"><$font_color>RPM Status:</FONT></TD>
<TD VALIGN="TOP" WIDTH="475"> |; print &build_select_field("RPM Status",$rec{'RPM Status'}); print qq|</TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="150"><$font_color>DPM Month:</FONT></TD>
<TD VALIGN="TOP" WIDTH="475"> <INPUT TYPE="TEXT" NAME="DPM Month" SIZE="8" VALUE="$rec{'DPM Month'}" MAXLENGTH="20"></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="150"><$font_color>DPM Goal:</FONT></TD>
<TD VALIGN="TOP" WIDTH="475"> <INPUT TYPE="TEXT" NAME="DPM Goal" SIZE="8" VALUE="$rec{'DPM Goal'}" MAXLENGTH="20"></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="150"><$font_color>DPM Status:</FONT></TD>
<TD VALIGN="TOP" WIDTH="475"> |; print &build_select_field("DPM Status",$rec{'DPM Status'}); print qq|</TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="150"><$font_color>Functional Test Yield Month:</FONT></TD>
<TD VALIGN="TOP" WIDTH="475"> <INPUT TYPE="TEXT" NAME="Functional Test Yield Month" SIZE="8" VALUE="$rec{'Functional Test Yield Month'}" MAXLENGTH="20"></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="150"><$font_color>Functional Test Yield Goal:</FONT></TD>
<TD VALIGN="TOP" WIDTH="475"> <INPUT TYPE="TEXT" NAME="Functional Test Yield Goal" SIZE="8" VALUE="$rec{'Functional Test Yield Goal'}" MAXLENGTH="20"></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="150"><$font_color>Functional Test Yield Status:</FONT></TD>
<TD VALIGN="TOP" WIDTH="475"> |; print &build_select_field("Functional Test Yield Status",$rec{'Functional Test Yield Status'}); print qq|</TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="150"><$font_color>Final Inspection Yield Month:</FONT></TD>
<TD VALIGN="TOP" WIDTH="475"> <INPUT TYPE="TEXT" NAME="Final Inspection Yield Month" SIZE="8" VALUE="$rec{'Final Inspection Yield Month'}" MAXLENGTH="20"></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="150"><$font_color>Final Inspection Yield Goal:</FONT></TD>
<TD VALIGN="TOP" WIDTH="475"> <INPUT TYPE="TEXT" NAME="Final Inspection Yield Goal" SIZE="8" VALUE="$rec{'Final Inspection Yield Goal'}" MAXLENGTH="20"></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="150"><$font_color>Final Inspection Yield Status:</FONT></TD>
<TD VALIGN="TOP" WIDTH="475"> |; print &build_select_field("Final Inspection Yield Status",$rec{'Final Inspection Yield Status'}); print qq|</TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="150"><$font_color>Overall Status:</FONT></TD>
<TD VALIGN="TOP" WIDTH="475"> |; print &build_select_field("Overall Status",$rec{'Overall Status'}); print qq|</TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="150"><$font_color>Overall Status Summary:</FONT></TD>
<TD VALIGN="TOP" WIDTH="475"> <TEXTAREA NAME="Overall Status Summary" ROWS="4" COLS="40" WRAP="VIRTUAL" MAXLENGTH="1000">$rec{'Overall Status Summary'}</TEXTAREA></TD></TR>
|;
if ($per_admin) {
print qq|
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="150"><$font_color>SE Approval:</FONT></TD>
<TD VALIGN="TOP" WIDTH="475"> |; print &build_select_field("SE Approval",$rec{'SE Approval'}); print qq|</TD></TR>
|;
}
else {
print qq|
<input type="hidden" NAME="SE Approval" VALUE="$rec{'SE Approval'}">
|;
}
print qq|
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="150"><$font_color>Counter:</FONT></TD>
<TD VALIGN="TOP" WIDTH="475"> <INPUT TYPE="TEXT" NAME="Counter" SIZE="5" VALUE="$rec{'Counter'}" MAXLENGTH="10"></TD></TR>
</TABLE>
|;






}

I have to leave the office soon so you might not get a reply until Monday but thanks for all your help so far.

Have a nice weekend
Elle


Quote Reply
Re: Entering Data Externally via links In reply to
Code:

my (%rec) = @_;
($db_auto_generate and print &build_html_record_form(%rec) and return);


if ($in{'add_form'}) {
$rec{'Platform'} = $in{'Platform'};
$rec{'Customer'} = $in{'Customer'};
$rec{'Commodity'} = $in{'Commodity'};

}

my $font_color = 'Font face="Verdana, Arial, Helvetica" Size=3 Color=#003399';

print qq|
<TABLE WIDTH="450" CELLPADDING=0 CELLSPACING=0 BORDER=1 BGCOLOR="#FFFFCC">

<input type=hidden name="Platform" value="$rec{'Platform'}">
<input type=hidden name="Customer" value="$rec{'Customer'}">
<input type=hidden name="Commodity" value="$rec{'Commodity'}">


<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="150"><$font_color>Part Number
:</FONT></TD>
JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Entering Data Externally via links In reply to
Hi

This got rid of the server error that i was encountering but the | symbol still appears in the Platform and commodity fields when i view the data. I have the debugging mode enabled and it shows that the data is being passed in with ~~ attached to the end they only appear after the user has submitted the form. I don't know if this is of any help to you or not. Do you need to see more of my code?

Elle

Quote Reply
Re: Entering Data Externally via links In reply to
I think we can work this out without having to look at the file.

Which subroutines have the hidden fields in them? Just list the names of the subroutines.

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Entering Data Externally via links In reply to
sub html_record_form - but only in the form that you showed above.

sub html_login_form and sub html_login_failure in the form of - <input type=hidden name="Platform" value="$in{'Platform'}">


Quote Reply
Re: Entering Data Externally via links In reply to
Wait a minute. I just looked over your subroutine again.

You have


<TR><TD ALIGN="Right" VALIGN="TOP"
WIDTH="150"><$font_color>Customer:</FONT></TD>
<TD VALIGN="TOP" WIDTH="475"> |; print &build_select_field("Customer",$rec{'Customer'});
print qq|</TD></TR>



<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="150"><$font_color>Platform:</FONT></TD>
<TD VALIGN="TOP" WIDTH="475"> <INPUT TYPE="TEXT" NAME="Platform" SIZE="20"
VALUE="$rec{'Platform'}" MAXLENGTH="255"></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"
WIDTH="150"><$font_color>Commodity:</FONT></TD>
<TD VALIGN="TOP" WIDTH="475"> <INPUT TYPE="TEXT" NAME="Commodity" SIZE="20"
VALUE="$rec{'Commodity'}" MAXLENGTH="255"></TD></TR>


You should only have one field per form with the same name. You could just delete the hidden fields, since you have them on the form already. (I was just looking at the reason for the syntax error and not the rest of the subroutine.)

You really only need the hidden fields in the subroutines where a person might go if he was logging in, in order to pass on the variables.

Am I making any sense at all? Smile

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Entering Data Externally via links In reply to
erm ... so take out all the hidden field stuff i.e. <input type=hidden etc> in all the sub routines or just sub html_record_form?

Elle

> >