Gossamer Forum
Home : Products : DBMan : Customization :

problems with &get_email

Quote Reply
problems with &get_email
Hi,

i have integrated the secure PW mod into my DB. Everything works exept the &get_email function.
In the .cfg I entered &get_email as default. All I receive is the following error message when adding a new address.
"not found in password file"

When I replace
if ($db_userid eq $userid) {
with
if ("MrX" eq $userid) {
the email address of Mr X is displayed.

What am I doing wrong?

I attached my get_email mod.

Thank you for the help!

Jakob


sub get_email {
# --------------------------------------------------------
# Pulls the email address from the password file.
### Following subroutine added for secure_password_lookup mod

my ($userid, $pw, $view, $add, $del, $mod, $admin, $view_all, $email, $db_userid);

open (PASSWD, "<$auth_pw_file") || &cgierr("unable to open password file. Reason: $!\n");
@passwds = <PASSWD>;
close PASSWD;

foreach $pass (@passwds) { # Go through each pass and see if we match..
next if ($pass =~ /^$/); # Skip blank lines.
next if ($pass =~ /^#/); # Skip Comment lines.
chomp ($pass);
($userid, $pw, $view, $add, $del, $mod, $admin, $view_all, $email, $name, $vorname, $group) = split (/:/, $pass);
if ($db_userid eq $userid) {
return $email;
}
}
return "$db_userid not found in password file";
}


Quote Reply
Re: problems with &get_email In reply to
In Reply To:
In the .cfg I entered &get_email as default.
No. This is not correct.

I just put a note in the mod file not to do this.

Set your default value for the field to ''. Use the code in the mod to get the email address.





JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: problems with &get_email In reply to
Hi there,
somehow it is still not working..

I still receive a " not found in password file" in the email field. Notice... There is no user name before the message.

What could be wrong??????

Thanks for the help!
Jakob

sub html_record_form {
# --------------------------------------------------------

my (%rec) = @_;
if ($in{'add_form'}{
$rec{'eMail'} = &get_email;
}

($db_auto_generate and print &build_html_record_form(%rec) and return);

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

print qq|


Quote Reply
Re: problems with &get_email In reply to
What other mods are you using? Are you by any chance using the "add record at time of signup" mod, or "force new user to add record"?

Is the code you posted the only place where you have the &get_email?

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: problems with &get_email In reply to
Hi,

there is no other call of get_email... I am not using one of the mentioned mods...

Jakob


Quote Reply
Re: problems with &get_email In reply to
Okay. We'll start doing some debugging to see if we can figure it out.

Somewhere near the beginning of sub html_add_form, within a print statement, add

<P>--$db_userid--<P>

That will test to be sure that the $db_userid variable exists. You should end up with something like

--userid--

on your page.

Let me know what happens.

(I won't be online for quite a while, so you won't get a response from me until late tonight.)

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: problems with &get_email In reply to
Hi,

that worked!!

Jakob

Quote Reply
Re: problems with &get_email In reply to
Okay. Then the $db_userid variable is set when the add form is called.

Which means it is set when sub html_record_form is called.

I need you to open your .cfg, db.cgi and html.pl files in a text editor and do a search in each one for &get_email. It should only be in sub html_record_form. Since you're getting the error message without a userid attached, that means it is being called somewhere before the $db_userid has been defined.

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: problems with &get_email In reply to
Hi,

I don't know what is wrong, however the search only return one &get_email and that was in the html.pl file.

I also tried &get_email($db_userid). No luck

Jakob

Quote Reply
Re: problems with &get_email In reply to
Hi,

I just also installed the multiple select field mod that you wrote.
Here I get the following message:
error building select field: no fields specified/unkown field ()!
Could these problems be linked???

Jakob

Quote Reply
Re: problems with &get_email In reply to
Hi,

you can take a look at my skrips at:
http://www.ndh.com/home/moehs/db.cgi
http://www.ndh.com/home/moehs/default.cfg
http://www.ndh.com/home/moehs/html.pl
http://www.ndh.com/home/moehs/auth.pl

That server doesn't support cgi, so the files should be shown as normal text.

Thank you!

Jakob

Quote Reply
Re: problems with &get_email In reply to
I don't know what either problem is, but I would really appreciate it if you didn't add any more mods until you get the current ones working correctly.

In sub html_record_form, after

if ($in{'add_form'}) {

add

print "<P>--$db_userid--<P>";

And change

$rec{'eMail'} = &get_email($db_userid);

back to

$rec{'eMail'} = &get_email;

Also, in sub get_email, add

print "<P>--$db_userid--(get_email)<P>";

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: problems with &get_email In reply to
Hi,

here is what happend:
--Admin--
----(get_email)

Thank you very much for your help!

Jakob

Quote Reply
Re: problems with &get_email In reply to
I finally found it.

In sub get_email, you have

my ($userid, $pw, $view, $add, $del, $mod, $admin, $view_all, $email, $db_userid);

By including $db_userid in the "my" definition, you are emptying the variable for the subroutine.

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: problems with &get_email In reply to
Hi,

HURRAY!!!! That was the trick!!! Now the email is inserted!!!

THANX!!!

Jakob

Quote Reply
Re: problems with &get_email In reply to
Hi,

would you also be so kind and take a look why at my 2nd problem?

Thank you very much in advance!

Jakob

Quote Reply
Re: problems with &get_email In reply to
# my ($column, $value, $size) = @_;
# my (@fields, @values, $ouptut);

The second line being commented out won't cause much problem, but the first line is where the subroutine gets the values you're sending it.

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: problems with &get_email In reply to
Hi,

sorry for the bother!!!! Both were caused my simple mistakes by me!!! So, sorry!
I have know idea why I didn't unkomment the first two lines...
I did it in the first place, because I found didn't find the mistake in the mod that I had used at first. There was no time to search this morning, because work was waiting...

http://www.gossamer-threads.com/perl/forum/showthreaded.pl?Cat=&Board=DBCust&Number=83290&page=&view=&sb=&vc=1#Post83290

That link leads to the mod. However in @values = split (/\Q$db_delim\E/,$value); } the last bracket hast to be omitted.

So anyway, thank you very much for your help!!!

Jakob


Quote Reply
Re: problems with &get_email In reply to
Thank you for pointing that out. I edited the post.

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: problems with &get_email In reply to
Hi there,

I still have two problems:
1) When I go into the search function, the email address is displayed. What shall I do?
2) The multi select field seems to work, however the values are not saved.

My personal mod
As admin I want to be able to edit a email adress in the db. So I entered another email field at the bottom.
I have uploaded the files to same place as mentioned abouve.

Thank you for the help!

Jakob

Quote Reply
Re: problems with &get_email In reply to
In Reply To:
1) When I go into the search function, the email address is displayed. What shall I do?
The current user's email address is displayed on the search form?

I tried to log in to your site to try to see what was happening, but when I tried to sign up for an account, the browser timed out. Could you set up an account for me so I can access the database?

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: problems with &get_email In reply to
Hi,

JpDeni, sorry if I disapointed you in some way. It defenatly wasn't on pupose.

I habe been able to close in on the error with the multi selcet field.
If I add a new person to my database and in the form use the multi select field the entry is transfered as "selection1~~selection2" (I'm using the preview mod) in the preview. After clicking "add it" the entry isn't saved.
However, if I use modify the entries in the multi select field are added "selection1|selection2"

What could the problöem be?

Thank you for the help!

Jakob


Quote Reply
Re: problems with &get_email In reply to
Ah-ha!

At the beginning of sub html_preview, add

$in{'FieldName'} =~ s/~~/$db_delim/g;



JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: problems with &get_email In reply to
Hi there,

Thank you!!! That was it! Smile

What does that line do exactly?

Jakob

Quote Reply
Re: problems with &get_email In reply to
It substitutes every instance of ~~ with the character defined as your delimiter.

When a multiple selection is sent to the script, the selections are separated by ~~. That's what is saved to the .db file. When the .db file is read and "decoded," the ~~ is replaced by a |. Take a look at sub split_decode in the db.cgi file. That is where the lines from the .db file are split into the hash and some decoding is done.

sub build_multiple_select_field looks for the delimiter to see if there are multiple selections, because usually values have already been decoded when they are sent to the subroutine. It splits the selections into an array at the delimiter. But, since the data going to the preview has not yet been decoded, the subroutine doesn't know to split the values. It thinks it's all one value, which does not exist in the select field, so you get nothing selected.

So the line I gave you decodes the value so the subroutine knows where to split it.

Does that make any sense?

JPD
http://www.jpdeni.com/dbman/