Gossamer Forum
Home : Products : DBMan : Installation :

Automaticly fill in fields

(Page 1 of 2)
> >
Quote Reply
Automaticly fill in fields
Is it possible, to fill in the fields, whitch are known by the programm, as emailadress, and when the user added a second or more record, the 'name', 'adres', 'city', 'telephone', 'emailadres', etc., fields from the older record so the user don't have to fill these fields again?
Quote Reply
Re: Automaticly fill in fields In reply to
Yes.

In html.pl -- sub html_add_form

before

&html_print_headers;

add

Code:
%rec = &get_defaults;
undef %in;
$in{'Userid'} = $db_userid; # change to the actual fieldname you use for user id
my ($status,@hits) = &query("view");
if ($status eq "ok") {
$rec{'fieldname'} = $hits[fieldnumber];
}

Adjust the line

$rec{'fieldname'} = $hits[fieldnumber];

to match the field names and field numbers you want to transfer. Repeat the line as many times as you need to to fill in the fields you need.

change

&html_record_form (&get_defaults)

to

&html_record_form (%rec)


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





Quote Reply
Re: Automaticly fill in fields In reply to
I don't think this works correctly.
I have made an extra sub: html_remove_form.
I change the 'html_add_form(&get_defaults)', where you let me change &html_record_form(&get_defaults) in ...(%rec), I did that by "&html_remove_form(&get_defaults)' that stand under "&html_record_form(&get_defaults)', too, but I think, there is the bug.
When I add a record, the email works, the add_succes show up, but when I click on the link, there is a search-failure. When I check the DB, there is NO record added. When I block the added lines in the sub html_add_form and change the other rules in the original stste, the whole thing worked correct. Do you see the fault???

Oh yes, when I will add for the second time in one login session, the older values are not fill in in the new add screen.

[This message has been edited by mart (edited April 03, 1999).]
Quote Reply
Re: Automaticly fill in fields In reply to
Without knowing the structure or purpose of your html_remove_form subroutine, I can't even comment on what might be the problem.


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





Quote Reply
Re: Automaticly fill in fields In reply to
I place the files in the dir: 'http://www.autorandstad.nl/ftp/pub/' as auth_pl.txt, db_cgi.txt, default_cfg.txt, default_count.txt, default_db.txt, default_log.txt, default_pass.txt, html_pl.txt, please let me know, how you come to the files, because I, as a anounymous login, it failes, and with my browser also.
Quote Reply
Re: Automaticly fill in fields In reply to
I shall try, (my English...)
I made that subroutine, because, when a user adds a record, he must fill in the number of days, the record will stay in the DB,( autodelete) and also his name, city and telephone number. For the adding part this sub is called, right under 'html_record_form'. But when a user will search for a record, he don't need to know the number of days that the record will stay in the DB and also the name, city and number of that owner of the record is not important, so in the search sub, that 'html_remove_record' is not called.
I hope, that this is clear for you, otherwise I see it. Thank you.
Quote Reply
Re: Automaticly fill in fields In reply to
I'll try to describe what I think you mean and you can tell me if it's correct, okay? Smile

You have the html_record_form that has the fields a user can search on. And you have html_remove_form that has extra fields you need a user to fill out, but are not searchable. In your html_add_form you have (before you added the mod)

&html_record_form(&get_defaults);
&html_remove_form(&get_defaults);

The information you wish to copy from a previous record is contained in html_remove_form.

Is this correct?

If so, be certain that the first line of html_remove_form is

my (%rec) = @_;

I think that it might be a good idea for you to copy your html.pl file to an accessible directory on your website and rename it to html.txt. Then let me know where it is and I'll take a look at it.


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





Quote Reply
Re: Automaticly fill in fields In reply to
Sorry, but how do I make a dir accesseble??!
I know, that it has something to do with rights, but I do not know the chmod commands.
Quote Reply
Re: Automaticly fill in fields In reply to
Just place it in a regular web page directory, where your plain html files are. You just cannot have it in your cgi bin, because I wouldn't be able to see access it then.


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





Quote Reply
Re: Automaticly fill in fields In reply to
I wasn't able to access them either.

Do you have a directory within your webspace where you put html files? Do you have an index.html file anywhere on your webspace? If you do, copy the files to the same directory as your index.html file.


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





Quote Reply
Re: Automaticly fill in fields In reply to
At this moment, I have a big problem: No one can acces my whole site, I've been experimented with the permissions, now I don't know how to put it back. Do you know???? I've mailed my webmaster, but I do not expect any answer before next tuesday, so that means, that my server is dead during one or two days. What do I have to do???
Quote Reply
Re: Automaticly fill in fields In reply to
I now will post them on http://www.automart.nl/ , I hope you can enter there, let me know if not.
Quote Reply
Re: Automaticly fill in fields In reply to
I don't what to tell you about fixing your permissions. You may have to wait until your server admin gets back to you.

I did see your page at http://www.automart.nl/html_pl.txt

I saw a problem with your entering of the mod. (I'm sure you thought I'd made a typo, since I do make them a lot, but not this time.)

You have

$rec{'Date'} = $hits['2'];
$rec{'Email'}=$hits['16'];
$rec{'Verwijder'}=$hits['18'];
$rec{'Naam'}=$hits['20'];
$rec{'Woonplaats'}=$hits['21'];
$rec{'Telefoon'}=$hits['22'];

You need to have

$rec{'Date'} = $hits[2];
$rec{'Email'}=$hits[16];
$rec{'Verwijder'}=$hits[18];
$rec{'Naam'}=$hits[20];
$rec{'Woonplaats'}=$hits[21];
$rec{'Telefoon'}=$hits[22];

Also, in reading some of what you said earlier I saw
Quote:
When I block the added lines in the sub html_add_form and change the other rules in
the original stste, the whole thing worked correct.

What "other rules" do you mean? The only thing I gave you here were lines to add to html_add_form. Possibly it's the "other rules" that are causing the problem.

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





Quote Reply
Re: Automaticly fill in fields In reply to
By 'othet rules' I meant the changes in the references to the sub's '&html_record_form'(&get_defaults)' to '&html_record_form(%rec)' and 'html_remove_form(&get_defaults)' to 'html_remove_form(%rec)', I think this won't have any problems. I try it, when the site is working so I'll put the result here. Thanks.

Mart Kruijt.
Quote Reply
Re: Automaticly fill in fields In reply to
Okay, we're going to have to do some debugging.

The changes I suggest you make are temporary, just so we can see what's going on.

After

<$font_title><b>
Voeg een nieuw record toe
</b></font></center><br>

add

$status<BR>

(This is still within the print qq| statement.)

Try adding a second record for a user. You should get the word "ok" printed on your screen, just below the title of the page. This will tell us if the &query statement is working correctly.

If you see "ok," add the following lines (still within the print qq| statement):

$rec{'Date'}<BR>
$rec{'Email'}<BR> $rec{'Verwijder'}<BR>
$rec{'Naam'}<BR>
$rec{'Woonplaats'}<BR>
$rec{'Telefoon'}<BR>

You should get the information for the user printed on your page.

Let me know what happens.


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





Quote Reply
Re: Automaticly fill in fields In reply to
Hoi,
The rule, that appear is: 'no matching records.', so I did only the first part of your comment. I wait for your answer,
---------
Thanks,
Mart.
Quote Reply
Re: Automaticly fill in fields In reply to
I've made the changes, now, in the beginning, it worked correct, but when the same user want to add his second record, he still must fillin his email, name, ...., and thats what this was all about, am I forgotten something? The html_pl.txt in my site is updated.
Thanks again.

Mart
Quote Reply
Re: Automaticly fill in fields In reply to
Aha! It's not finding the previous record. Well, that tells me something, but I'm not sure what.

Let's make sure your search term is right. Instead of the printing out $status, substitute $db_userid.

Also, you might want to take out the line

undef %in;

although I don't think that will make a difference.




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





Quote Reply
Re: Automaticly fill in fields In reply to
The UsertId is given right. The blocking from the line, you gave, make no difference. Is it become clear now??
Quote Reply
Re: Automaticly fill in fields In reply to
I really don't understand this.

If the Userid is correct, then setting $in{'Userid'} and doing a query should end up giving you some results. (I didn't think that changing the "undef %in" would help, but I was grasping at anything I could think of.)

I went to your site to try it out, but I couldn't add a record. (It's a lot easier for me if I can actually see what's happening.)

I am completely stumped. I have used this same structure a number of times and it's always worked for me.

I welcome anyone else who has a suggestion!


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





Quote Reply
Re: Automaticly fill in fields In reply to
Now I'm really confused.

Quote:
The $db_userid is in my .cfg, defined by 'Userid' and not 'userid'.

$db_userid is not defined in your .cfg file at all. It may have a similar name to your "Userid" field, but it is not the same thing. $db_userid is a variable that is defined in the db.cgi script and is set to the current user name.

I see the change you made in html.pl

$in{'Userid'} = $db_Userid;

Change it back to

$in{'Userid'} = $db_userid;

My note to
# change to the actual fieldname you use for user id
refers to the $in{'Userid'} part of the line, not the $db_userid.

I see that the $status is now "no search terms specified." That will change when you fix the $db_userid.

Quote:
The '$Date' and '$Remove' give a good result.

I'm not sure what you mean here. (Probably a language problem.) I still cannot add a record to the database to try it out for myself. There is something wrong with the "Remove" field. I set the
"Hoelang moet uw auto in de Database blijven staan?" to "14" and I get an error message

Remove (Too long. Max length: 5)

There is no point in working on a new feature until this is fixed.

Here's what I would suggest. Delete everything in your current database. Set autogenerate to 1 in your .cfg file. Take out the line (temporarily) in html_add_form -- &html_remove_form (%rec);

Add some records. Let me know when you've done it and I'll add some, too. At least then we'll know that the database is correct.

Aha! I just looked again at your .cfg file. You have

Userid => [17,'alpha',

and

$auth_user_field =18;

You need to make these the same.

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





Quote Reply
Re: Automaticly fill in fields In reply to
I'm sure that was why I couldn't add a record to your database. It told me that "Verwijder" was too long (maximum of 5 characters), when I had left the default "14" in the field.

Did you define "$db_verwijder" somewhere? I didn't find it in any of your scripts. Or are you referring to "$rec{'Verwijder'}"?

There is a real problem with your database if you are getting the fields messed up. You might try starting over with a blank database to see if that will fix it up.

I also notice that on your home page it says there are 3 records in the database, but there are actually 4. I did a search for your first record (BMW) and it said there were no matching records. The source of the problem is not immediately obvious, but it seems there is something with that record. You might try just removing the first record and see what happens.

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





Quote Reply
Re: Automaticly fill in fields In reply to
I think I found one bug: The $db_userid is in my .cfg, defined by 'Userid' and not 'userid'. So I change that, and now the '$status' give 'no matching records'. The '$Date' and '$Remove' give a good result. My html_pl.txt in the dir. of my site is updated. I hope, you can get any further with this, because I don't know, where to search...
Quote Reply
Re: Automaticly fill in fields In reply to
I found out, that when you ask the value of '$db_verwijder' (has the value of how many days the record will stay in the DB) it gives me the value of '$db_userid'. I hope you can get further with this.
Quote Reply
Re: Automaticly fill in fields In reply to
GREAT!!!, It all works now. Thanks, and my apollogies for this mistake. I'll post another one...
> >