Gossamer Forum
Home : Products : DBMan : Installation :

form length (-2) and 40x3

Quote Reply
form length (-2) and 40x3
Hi,

Can anyone tell me how I can have a 40col x3row which is hidden (-2 - admin only).

I want default users to enter details into this field but, while viewing. it should not appear to any user except admin.

--
Heres's my db_def : I want these 4 files to be shown while adding, but it should not appear on viewing to anybody except admin.
----------
Name => [6, 'alpha', 40, 255, 1, '', ''],

Year_of_Birth => [7, 'numer', 4, 4, 1, '', ''],

Contact_Address => [8, 'alpha', '40x3', 500, 1, '', ''],

Contact_Email_ID => [9, 'alpha', 40, 100, 1, '', '@'],

-------

Thanks in advance.

Joe
Quote Reply
Re: form length (-2) and 40x3 In reply to
Hi Joe,

As far as I understand it, the -2 will only work wif you are using auto_generate.

If you just want your admin to view it you can put an if condition in your html_record

if ($per_admin) {....}
Quote Reply
Re: form length (-2) and 40x3 In reply to
Hi Joe,

As far as I understand it, the -2 will work with auto_generate.

If you just want your admin to view it you can put an if condition in your html_record

if ($per_admin) {....}
Quote Reply
Re: form length (-2) and 40x3 In reply to
Jaime:

Could you please explain how to do this a little bit further? If possible, please include an example. The reason I'm asking is because I'm still at the learning stage when it comes to CGI/Perl.

Thanks!
Quote Reply
Re: form length (-2) and 40x3 In reply to
Yes, Jaimie

I have Auto_generate enabled..

Can you be a little more specific, please? What code, do I have to alter and where?

Here's what I'd like to achieve :

In the add form, viewers should be able to add their name, address and email address to the form. (please see the 1st posting on this list)

But, while viewing they should see everything else except the name, address and email address.

Admin however should be able to see everything...
-------------------------
One mpre thing : I'd like the email addresses to be clickable too (like in the usual mailto:me@me.com)
Quote Reply
Re: form length (-2) and 40x3 In reply to
Yes, Jaimie

I have Auto_generate enabled..

Can you be a little more specific, please? What code, do I have to alter and where?

Here's what I'd like to achieve :

In the add form, viewers should be able to add their name, address and email address to the form. (please see my db_def on the 1st posting on this list)

But, while viewing they should see everything else except the name, address and email address.

Admin however should be able to see everything...
-------------------------
One mpre thing : I'd like the email addresses to be clickable too (like in the usual mailto:me@me.com)
Quote Reply
Re: form length (-2) and 40x3 In reply to
Hi Joe, David...

With auto_generate set to true and the -2 set in the field, I donīt think you will be able to have users add into the fields but not view them afterwards. If they can add to them, they will be able to view them. The -2 is intended for an admin field all the way around and only admin people will be able to work with it (view, add, modify...).

Now, even though the auto_generate feature will get you started, it is only a matter of time before you will try to customize the look of dbman. To do that, auto_generate cannot longer be used. You will have to modify the different subroutines that deal with the presentation of dbman (html_record_form,html_record,...)

So, with auto_generate set to 0, this is how you would accomplish your add/view question.

For everybody to be able to ADD stuff in your fields, you will have to work with the html_record_form sub where you will set up all the different inputs. I am sure you can figure out the syntax once you look at the existing sub.

For resticting the view of the data to everybody but the admins you will have to work with the html_record sub. Below is an example of a simplified html_record sub where I am hidding the field XXX from everybody but admins

Code:
print qq|
<TABLE WIDTH="475" CELLPADDING=0 CELLSPACING=0 BORDER=1 BGCOLOR="#FFFFCC">
<TR><TD ALIGN="Right" VALIGN="Center" WIDTH="25%"><$font_color>Whatever</FONT></TD>
<TD> <$font>$rec{'Whatever'}</Font></TD></TR>
|; if ($per_admin) { print qq|
<TR><TD ALIGN="Right" VALIGN="Center"><$font_color>XXX</FONT></TD>
<TD> <$font>$rec{'XXX'}</Font></TD></TR>
|; } print qq|
</TABLE>

Notice the "print qq|" and "|;". They are important. Alex explained how to use print qq| in his README file. The if ($per_admin) piece of the code is whatīs doing the trick.

Let me know if only managed to confuse you more Smile

What do you mean by having a clickable e-mail address? What exactly do you want to?

Cheers
-JO
Quote Reply
Re: form length (-2) and 40x3 In reply to
Hi again,

I just read another post initiated by David Tan in which JPD (a regular in this forum who answers anybody she can... thanks again) goes through some of the same stuff I tried to explain. Check out the post

http://www.gossamer-threads.com/scripts/forum/resources/Forum5/HTML/000478.html

Cheers
-JO
Quote Reply
Re: form length (-2) and 40x3 In reply to
O.k., Jaimie,
I've disabled auto generate form, next I modified the html_record and html_record_form.

But after uploading, i get this error :
=======================================
Reason: Can't use global @_ in "my" at ./html.pl line 98.
=======================================

I've included below part of my html.pl -->


sub html_record {
# ---------------------------------------------

my (%rec) = @_; # Load any defaults to put in the VALUE field.
($db_auto_generate and print &build_html_record(%rec) and return);



Do I need to change anything here?
Quote Reply
Re: form length (-2) and 40x3 In reply to
Hi Joe

Can you put the code in a location where we can look at it? (Remember to put them as text files)

I canīt see anything wrong with those 2 lines...

Cheers
-JO
Quote Reply
Re: form length (-2) and 40x3 In reply to
Jaime:

Thanks for the help. I have decided to make use of the html.pl's configurability and do up my own html coding. However, I have encountered a glitch when trying to implement the if() routine. When I run the db.cgi script, I get the following error...

CGI ERROR
==========================================
Error Message : Error loading required libraries.
Check that they exist, permissions are set correctly and that they compile.
Reason: Bad name after UserID:: at ./html.pl line 285.

Below is a snapshot of my html.pl script.

++++++++++++
sub_html_record {
.
.
.
if ($per_admin) {
print qq|
<tr><td align="Right" valign="TOP" width="150" bgcolor="#FFCC66">
<div align="right"><i><font face="Helvetica, Arial, sans-serif" size="2">Number</font></i></div>
</td>
<td colspan="2" bgcolor="#FFCC66"> $rec{'No'}</td>
</tr>
<tr><td align="Right" valign="TOP" width="150" bgcolor="#FFCC66">
<div align="right"><i><font face="Helvetica, Arial, sans-serif" size="2">UserID</font></i></div>
</td>
<td colspan="2" bgcolor="#FFCC66"> $rec{'Title'}</td>
</tr>
|;
}


print qq|
[Line 285==>] <tr><td align="Right" valign="TOP" width="150" bgcolor="#FFD631">
<div align="right"><i><font face="Helvetica, Arial, sans-serif" size="2">First</font></i><b><i><font face="Helvetica, Arial, sans-serif" size="2">
</font></i></b><i><font face="Helvetica, Arial, sans-serif" size="2">Name</font></i></div>
</td>
<td colspan="2" bgcolor="#FFD631"> $rec{'First Name'}</td>
</tr>
<tr>
<td align="Right" valign="TOP" width="150" bgcolor="#FFD631">
<div align="right"><i><font face="Helvetica, Arial, sans-serif" size="2">Last
Name or Surname</font></i></div>
</td>
.
.
.
++++++++++

I have checked the permissions settings and they are exactly as prescribed in your readme file. The funny thing is that there is no such error in the previous if() statement in the previous sub html_record_form subroutine.

Do you see and error in my script????

Regards and thanks!
David
Quote Reply
Re: form length (-2) and 40x3 In reply to
Hello Jaimie..

Thank you very much for your help.
Please visit this address :
http://www.freeyellow.com/members6/joe99/index.html

Regds
Joe
Quote Reply
Re: form length (-2) and 40x3 In reply to
Hello Joe,

I just looked at your html.pl file and I think I found what is wrong with it.

Check the first subroutine you have, you forgot to put a name for it.

sub ???? {
....
....
}

I guess it should be sub html_record_form

Cheers
-JO
Quote Reply
Re: form length (-2) and 40x3 In reply to
Hi David,

A couple of things that you might have forgotten...

before
Code:
if ($per_admin) {
print qq|


you should always have a |; (I donīt know if you have one or not and I am assuming that you have html before it.)

Make sure that you have as many { as you have }. I only see one, and I donīt know if it is supposed to close the if statement or the sub statement.

Just like with Joe, a URL where we can look at the file is always very helpfull.

cheers
-JO


Quote Reply
Re: form length (-2) and 40x3 In reply to
 
Is this what you mean, jaimie?
Do I have to put my database name there like this For Instance -->

sub {Employee Finder
#

Or is it somewhere else. It'd be a big help if you could explain what i should include and where..Thanks.
Joe
(Please see below :

##########################################################
## Record Layout ##
##########################################################

sub {
# --------------------------------------------------------
# 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.
Quote Reply
Re: form length (-2) and 40x3 In reply to
Hello Jaimie,

Please ignore my last posting. This is the change I made. Please see below :

##########################################################
## Record Layout ##
##########################################################

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


I changed it. Now this is the error I got ==>

CGI ERROR
==========================================
Error Message : Error loading required libraries.
Check that they exist, permissions are set correctly and that they compile.
Reason: Missing right bracket at ./html.pl line 1268, at end of line
syntax error at ./html.pl line 1268, at EOF

1268 lines, whew! Is there an easy way to get to line 1268 ? Could you please add the missing bracket on line 1268 and paste it here. Thanks..

- Joe Louis
Quote Reply
Re: form length (-2) and 40x3 In reply to
Hi Joe,

Unfortunately, missing bracket errors are usually somewhere above the line that the error tells you.

Are you using UNIX or NT? If using NT, there is a text editor that I swear by called GWD. Search for it in the web and try it out. If you are using UNIX then it depends on what editor you are using.

Anyway, I looked at your html.pl file again, and this is what is wrong...

In your sub html_record you have

Code:
<TD> <$font>$rec{'Age'}</Font></TD></TR>
|; if ($per_admin) { print qq|
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Name:</FONT></TD>
<TD> <$font>$rec{'Name'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Address:</FONT></TD>
<TD> <$font>$rec{'Address'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Email:</FONT></TD>
<TD> <$font>$rec{'Email'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Date:</FONT></TD>
<TD> <$font>$rec{'Date'}</Font></TD></TR>
</TABLE>
|;
}

You are missing the closing brackets of the if condition.

it should look something like

Code:
<TD> <$font>$rec{'Age'}</Font></TD></TR>
|; if ($per_admin) { print qq|
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Name:</FONT></TD>
<TD> <$font>$rec{'Name'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Address:</FONT></TD>
<TD> <$font>$rec{'Address'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Email:</FONT></TD>
<TD> <$font>$rec{'Email'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Date:</FONT></TD>
<TD> <$font>$rec{'Date'}</Font></TD></TR>
</TABLE>
|;
} # Closing if
} # Closing sub

Cheers
-JO

Quote Reply
Re: form length (-2) and 40x3 In reply to
Hi Jaimie,

It worked..I was able to login after i made the changes you specified.

There's a new problem now Smile

I wanted just the name, email, address details to be hidden from the casual viewer.
Now the problem is ..the viewer cannot view anything. Search reults show matching results, but the results cannot be seen.
"List all" does not work too..

The admin part, however is perfect..

Any clues?

Regds
Joe
Quote Reply
Re: form length (-2) and 40x3 In reply to
Try

Code:
<TD> <$font>$rec{'Age'}</Font></TD></TR>|;
if ($per_admin) { print qq|
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Name:</FONT></TD>
<TD> <$font>$rec{'Name'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Address:</FONT></TD>
<TD> <$font>$rec{'Address'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Email:</FONT></TD>
<TD> <$font>$rec{'Email'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Date:</FONT></TD>
<TD> <$font>$rec{'Date'}</Font></TD></TR>|;
}
print qq|</TABLE>|;
}


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