Gossamer Forum
Home : Products : DBMan : Installation :

Cant get %rec over...

(Page 1 of 2)
> >
Quote Reply
Cant get %rec over...
I'll give up, perhaps I look over something, but I can't get the value of all the fields in the screen 'html_record_long' over to the script, for using it in another command.
I will give a registered user the possibillity to save the record in another named db, so he can call it back later with his own userid. I will get some info in the new db, but only '| || || || |'with only in the field for the userid the userid of the user, whitch was changed in the script-sub.
Maybe its too complicated, but for the beginning I only need to know the way of taking the value of the hash whitch build the record_long, to a sub in the .cgi. HELP...
Quote Reply
Re: Cant get %rec over... In reply to
Probably the best way to do this is to write directly to the other database. What commands are you using right now?


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





Quote Reply
Re: Cant get %rec over... In reply to
This part is in my .cgi:
Code:
sub add_record_pref {
# --------------------------------------------------------
# Adds a record to the preference-database.

# I've tried a lot in this 'my' part, but nothing works

my ( %rec, $output, $status );

# Set the userid to the logged in user.
($auth_user_field >= 0) and ($in{$db_cols[$auth_user_field]} = $db_userid);

# Change the date field to today.
$in{$db_cols[2]} = &get_date;

open (PREF, ">>/opt/guide/www.autorandstad.nl/cgi-bin/dbman/voorkeur.db") or &cgierr("error in add_record_pref. unable to open
database: /opt/guide/www.autorandstad.nl/cgi-bin/dbman/voorkeur.db.\nReason: $!");
if ($db_use_flock) {
flock(PREF, 2) or &cgierr("unable to get exclusive lock on /opt/guide/www.autorandstad.nl/cgi-bin/

dbman/voorkeur.db.\nReason: $!");
}
print PREF &join_encode(%in);
close PREF; # automatically removes file lock
}

# On this place, I think, I got the Internal 500 error

&auth_logging("heeft voorkeurslijst gemaakt") if ($auth_logging);
And with this link: <INPUT TYPE="SUBMIT" NAME="add_record_pref" VALUE="Voeg toe aan de voorkeurslijst"> the user put the record in the pref. list.
The userid comes in the place of the userid of the record-owner. If this is possible,it's good, because the list must be cleaned up in about 7 days.

I hadn't thought yet, how to call the list, but I think, there must become another .cfg file, or not???

Oh yes, I added also
Code:
elsif ($in{'add_record_pref'}) { if ($per_add) { &add_record_pref; } else { &html_unauth; } }
in my .cgi, but I think I will change the fault-destination to the log-in sub in my 'html.pl.



[This message has been edited by mart (edited July 31, 1999).]
Quote Reply
Re: Cant get %rec over... In reply to
You're probably going to need to create a whole form to go with your submit button. This is what I would try:

In html_record_long (which is where I assume you have your submit button), add

Code:
print qq|
<form action="$db_script_url" method="POST">
<input type=hidden name="db" value="$db_setup">
<input type=hidden name="uid" value="$db_uid">|;
foreach $col (@db_cols) {
print qq|<input type="hidden" name="$col" value="$rec{$col}">|;
}
print qq|
<INPUT TYPE="SUBMIT" NAME="add_record_pref" VALUE="Voeg toe aan de voorkeurslijst">
</form>|;

Then your sub add_record_pref should work. You can delete the line
my (%rec, $output, $status);

You'll also need to have somewhere for the script to go after it gets finished. What do you want the user to do after they add their pref?

The syntax of your subroutine is fine. You may be getting a 500 error because you're not sending them anywhere after they get finished with adding the pref.

You probably will need another .cfg file to call the list.


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





Quote Reply
Re: Cant get %rec over... In reply to
Well, this works, but now something I was affraid for: The checkbox searching part in the record_long will not work correct, because all the values are loaded in the variables. So when someone will press a checkbox, to search for the checked field, the search command takes all the values of all fields. Is there a way to make this work correctly???
Quote Reply
Re: Cant get %rec over... In reply to
The searching from off the record long is usefull, because a user can select a field with a checkbox, to take that as a search argument for a new search. Its a pity, that the part of 'preference list' will not work correctly. I made two new sub's in my html.pl, one I called 'html_add_pref_success', for the part, the user is going to, after he put a record in his pref.list and on I called 'html_record_pref', for the displaying of the record from the pref.list. The first sub works good, but only display an added record, added by the admin(?????????), can't figure that out... When that user ask for the preference list, it will display, in the 'short' display, but when he asked the long record, it will be displayed in the original 'html_record_long and not in my 'html_record_pref'. I made a little 'if' statement in my 'view_succes'
Code:
if ($db_total_hits == 1) {
if ($db_setup eq "voorkeur") {
&html_record_pref(&array_to_hash($_, @hits));

}
else {

&html_record_long(&array_to_hash($_, @hits));

}
else {

print qq|<align=left>
<p><table cellpadding=5 cellspacing=3 valign=top>
<tr><td>
# rest of the code
So I thougt everything was good, I also saw, when I call the pref.list with the link '<A HREF="http://www.autorandstad.nl/cgi-#bin/dbman/db.cgi?db=voorkeur&uid=$db_uid&ww=on&Userid=$userid&view_records=1&ID=*">' the value in 'db_setup' stays "voorkeur", and when I call 'list all, the records display from the 'default'db.
Pfffff, make sence???
Hope you can figure it out.

Thanks in advance.
-------
Mart.
Quote Reply
Re: Cant get %rec over... In reply to
No, Mart, I'm sorry. I just don't understand. Could you try once more, step by step to explain everything you want to accomplish?


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





Quote Reply
Re: Cant get %rec over... In reply to
I don't understand what you're doing, Mart. I thought you wanted there to be a button which would allow the user to add the current record to a separate database, with the user's name as the userid. Am I incorrect? Why does the user need to do a search?

BTW, there will probably to be a problem with your second database regarding the key field.

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





Quote Reply
Re: Cant get %rec over... In reply to
(Maybe too much...)
1. Visit my site at http://www.autorandstad.nl => Particulieren, => Alle records, => Select one record under 'Merk'. Now you in my 'Record_long'. You see the checkboxes behind some values. When a user click in one or more checkbox(es) and than click on 'Zoek Records', the script search the db for matching values for the clicked checkbox(es). So far so good.

2. The second part I want on this screen, is that a registered user can put this record in another db, with a 'submit' button somewhere in the screen. That record must be saved with the userid of the user who is doing this, so it can be called also with this userid. (maybe there is a safer way, only I don't know.)
I can now give you a whole story, from what I think of, how this can be done, but that makes it only more difficult.

The only thing, I figured out, is that the code you gave me for the %rec will kill my searching part because all the 'rec'-fields are filled with the original value.
Quote Reply
Re: Cant get %rec over... In reply to
I'm not sure why, but your checkbox thing doesn't work correctly. When I checked a box and then did the search, I came up with a result, but the links took me to the login screen instead of to the "long" record.

It's possible that the problem is that you have the form method as "POST." Try changing it to "GET" and see what happens. (All searches must use the "GET" method.)

The only thing I can think to do with your "save it to another database" thing is for you to create a second form, building hidden fields from the %rec hash like I gave you before. I don't see that this would be too much of a problem, since users aren't going to be doing a search and saving the record with just one click of a button.

You will still need to work out something for the key on the second database, though.


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





Quote Reply
Re: Cant get %rec over... In reply to
OK,
I will create a second form, with hidden fields, but how do I call that from the 'html_record_long' and is it possible to 'not show' this second form, only build the hidden fields and go to the .cgi. I thought, to implant the building of the hidden fields in the sub, that I made for this in the .cgi, but I haven't tried it yet. Somehow I get the feeling, this doesn't work. You were right about the 'POST' and 'GET' thing.
For the db key in the new db, maybe I can let the script change the ID field, before it writes to the new DB, just the way it change the userid, just have to make another .count file, am I right????

Thanks

--------
Mart.
Quote Reply
Re: Cant get %rec over... In reply to
You can make a second form right in sub html_record_long. After you print out the closing </form> tag for your search form, just add

Code:
print qq|
<form action="$db_script_url" method="POST">
<input type=hidden name="db" value="$db_setup">
<input type=hidden name="uid" value="$db_uid">|;
foreach $col (@db_cols) {
print qq|<input type="hidden" name="$col" value="$rec{$col}">|;
}
print qq|
<INPUT TYPE="SUBMIT" NAME="add_record_pref" VALUE="Voeg toe aan de voorkeurslijst">
</form>
|;

The only thing that will appear on your page is the button.

I think your key idea should work just fine.

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





Quote Reply
Re: Cant get %rec over... In reply to
I don't get any data in my html_add_suucess_pref sub, only empty fields...
Quote Reply
Re: Cant get %rec over... In reply to
You will probably have to define which .db file to look in, since the script will be looking in the first database for the $db_key.


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





Quote Reply
Re: Cant get %rec over... In reply to
I change the name of $db_key in $id_vk, in the new sub add_record_pref in the script and by the command in add_succes in html.pl,'&html_record_pref(&get_defaults($in{$id_vk}));' I change the 'key' too. So where do I have to look more???
Quote Reply
Re: Cant get %rec over... In reply to
Can you post the code, please, for both the subroutine where you add to the "pref" file and the subroutine that prints out the results? I will also need to know the name of your main .db file, the name of your "pref" .db file and the structure of both.


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





Quote Reply
Re: Cant get %rec over... In reply to
If you mean, if the fields are the same and on the same place in both .cfg files, its YES. I've posted the updated file to the same place. Nothing else is changed besides what you suggested.
Quote Reply
Re: Cant get %rec over... In reply to
I guess I should have asked this up front. Are the new records being written to the new database?


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





Quote Reply
Re: Cant get %rec over... In reply to
Its quit a big file, so I post it on http://www.autorandstad.nl/jpd_pref.txt
If you want it on the forum, I'll see that.

Thanks in advance.
Greetings,
-------
Mart.
Quote Reply
Re: Cant get %rec over... In reply to
That's fine.

Probably what you need to do in the beginning of

sub html_add_pref_success

is add a line

$db_file_name = $db_script_path . "/voorkeur.db";

One reason you're not getting the list is probably because it's looking in the wrong .db file.

The other problem I see is

&html_record_pref(&get_record($in{$id_vk}))

You do not have a variable "$in{$id_vk}" defined anywhere. You can change this to $id_vk, $in{$db_key}, or $in{'ID'}

Some nice coding, though. Smile I see you've come a long way since we first met!



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





Quote Reply
Re: Cant get %rec over... In reply to
Thank you,
still it don't display the data, I see the good record long, (the html_add_pref), but the fields are still empty, its just, the the values of %rec not came with the script to 'html_add_pref'.

BTW,
I've copied the code with the checkbox from the 'html_delete_form' to my 'html_record_pref' and put the following code in the 'delete' sub in the script, with the purpose to delete the record off the pref. list, only it won't work.
Code:
if ($db_setup eq "voorkeur") {
$db_file_name = "/opt/guide/www.autorandstad.nl/cgi-bin/dbman/voorkeur.db";
}

I think it's not so simple...

Thanks
Greetings
--------
Mart.

[This message has been edited by mart (edited August 03, 1999).]
Quote Reply
Re: Cant get %rec over... In reply to
One thing at a time, Mart. Let's get this working before you start on something else.

Could you update the file to include the changes you've made since my last post?

Quote:
still it don't display the data, I see the good record long, (the html_add_pref), but the fields are still empty, its just, the the values of %rec not came with the script to 'html_add_pref'.

What you need to get the %rec hash is to switch to the other database and to define a value for the $db_key. You say that the structure of your two databases is the same, right?

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





Quote Reply
Re: Cant get %rec over... In reply to
Sure, you can call them with the link, take a try, its on line now...
Quote Reply
Re: Cant get %rec over... In reply to
I couldn't find the link you were talking about -- just the .txt page. When I went to your main page, I got a completely blank frame.

What exactly is showing up (or not showing up) on your html_add_pref_success page? Are you getting the html_footer to show up? Looks to me like you have an extra </table> tag in there.

Code:
<P><Font face="Verdana, Arial, Helvetica" Size=2>Het volgende record is succesvol toegevoegd uw voorkeurslijst:<br><br>
</FONT></table>
|;
&html_record_pref(&get_record($in{'ID'}));
&html_footer; print qq|
</td></tr>
</table>
</center>
</body>
</html>
|;

You also have all the "top of page" html code in both sub html_record_pref and sub html_add_pref_success. I'm not sure what that will do, but it's probably better to have it one place or the other.


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





Quote Reply
Re: Cant get %rec over... In reply to
With a whole lot of puzzling, its works now.
Believe it or not, it was all depending of some auth settings in the 'voorkeur.cfg'.
Could you take a look again, to see if the 'blanc' screen is gone???

Thanks in adv.
Greetings,
-------
Mart.
> >