Gossamer Forum
Home : Products : DBMan : Customization :

View own single record via external URL

Quote Reply
View own single record via external URL
So I have my database set up properly now, field 8 "userid" is the key as well as the user ID (each user is allowed to make only 1 entry).

I want to create a cute little box on my page so they can enter userid (which is a 4 digit number) and password and simply view their record by clicking "Go" or whatever.


I thought that calling db.cgi?&view_records=1&$db_key=0000

Would call up the record for username 0000 ... but it isn't working... the user gets logged in properly, but I get an entry not found error or something of the sorts.

What should I be doing that I am not?



This is the last final absolute end of all of my questions.



for now.





:)
Quote Reply
Re: [astroboy5714] View own single record via external URL In reply to
Try calling the actual fieldname such as:

db.cgi?&view_records=1&userid=0000

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [astroboy5714] View own single record via external URL In reply to
I reckon you do have "db=database&uid=$db_uid" present in the query string as well?
kellner
Quote Reply
Re: [kellner] View own single record via external URL In reply to
Thanks Kellner, but yeah I have tried that... I even tried the following as all of my hidden inputs:



<input type=hidden name="db" value="default">
<input type=hidden name="view_records" value="1">
<input type=hidden name="uid" value="$db_uid">
<input type=hidden name="$db_key" value="3333">

To FORCE entry with key/username 3333 to come up and it said file not found... the user (3333) was logged in properly with the HTML form however. Argh.
Quote Reply
Re: [astroboy5714] View own single record via external URL In reply to
Quote:
<input type=hidden name="db" value="default">
<input type=hidden name="view_records" value="1">
<input type=hidden name="uid" value="$db_uid">
<input type=hidden name="$db_key" value="3333">



DBMan isn't going to understand those identifiers until after you're in the database scripts.

Try something like this:

<input type=hidden name="db" value="default">
<input type=hidden name="view_records" value="1">
<input type=hidden name="ID" value="*">



I've used "ID" because you've indicated that field is your key field, value="*" since you've indicated the key field and userid are one and the same and each user has only one record. "ID" would be the 'record identifier' you want to pull up.

I'm rambling trying to think of something that may work for you. Smile

~ Karen
Quote Reply
Re: [Karen] View own single record via external URL In reply to
hm. does it return a dbman generated error page or a server error page saying "file not found"?

in the latter case, this could be happening if you press the enter key to submit the form instead of the "submit" button. just guessing.
kellner
Quote Reply
Re: [Karen] View own single record via external URL In reply to
Thanks Karen, see my next post :)
Quote Reply
Re: [kellner] View own single record via external URL In reply to
Kellner,



No it is not a server error message, it is actually dbman.



I just had a thought though.



In all of these lines:



<input type=hidden name="db" value="default">
<input type=hidden name="view_records" value="1">
<input type=hidden name="uid" value="$db_uid">
<input type=hidden name="$db_key" value="3333">



You might think that this would bring up record with ID #3333 as long as user 3333 is logged in.

What if we operated this as a search... I think if we can tell dbman to list records where field #8 (entitled userid) = the userid that is entered we might be in business?

But is there a way to pass a single form entry to two separate entities? (Send it as the username itself, as well as field #8)



Though really there has to be a way to call a record simply by logging in and saying to get record # such and such.



Hmmmm ponder ponder ponder. :)
Quote Reply
Re: [astroboy5714] View own single record via external URL In reply to
Well, when you are passing these hidden input values, what you are effectively doing is carrying out a search for the user's record with the field "ID" (or whatever your database key is called). But the problem might be that you're trying to log them on at the same time.

So you're asking dbman to do two things at once: (a) log on, (b) search for the record. You can't really do this the way the script is setup.

In the standard setup, when you logon you are taken to the database home page, whose html is coded in html_home. You could simply add this code to html_home, wherever you want the user record printed:

if ($in{'login'}) { # if the user has just logged on

my %rec = &get_record ($db_userid);
&html_record(%rec);

}

This means: when the user has logged in, you take their username ($db_userid), which is the database key. Then you get the database record (and as I understand, there's only one record per user) and print it out.

If you're still getting error messages, please provide more exact information about what they are, whether they occur only when you call the script through the browser or also from the command-line, and so on.
kellner
Quote Reply
Re: [kellner] View own single record via external URL In reply to
Kellner!

I am excited by the prospect of this all actually working for me soon!


The file can be viewed in this way. Now this brings on a new problem.

There are 3 different ways to enter db.cgi from my page. #1 is "Create Your Account" (the user enters a username/password, and is automatically taken to the "Add Record" page). #2 is "Modify Your Record" (the user logs in and is automatically taken to the page to modify his/her record). #3 is what we have been working on "View Your Record".

Previously I had the html_home page automatically refresh to the Modify page (I had changed it to say "Loading your record ..." and then the page would refresh.)

Now I can not use this method, because if someone logs in to view their record, they are taken to the modify page automatically.


I think that using the method you gave me above, I may be able to have 2 separate html_home pages, and call them depending on the form that the user used to access db.cgi.




Thanks so much for everything!
Quote Reply
Re: [astroboy5714] View own single record via external URL In reply to
Yes, or you could just, on the "view your own record" form, code a hidden input field named "view_own".

Then, in html_home:

if ($in{'login'}) {

if ($in{'view_own'}) { # do stuff to view own record }

else { # do stuff to modify own record}

}
kellner
Quote Reply
Re: [kellner] View own single record via external URL In reply to
Kellner,





You rule.
Quote Reply
Re: [astroboy5714] View own single record via external URL In reply to
Finally! Wink
kellner