Gossamer Forum
Home : Products : DBMan : Customization :

Userid keeps popping up!

Quote Reply
Userid keeps popping up!
Hi,

I've slogged over DBMan for the last day and half and finally got it running pretty well and fairly well customized.

However, I keep getting a stange problem: when a user adds a record, the userid gets printed in one of the fields.

Here's my .cfg file:

Code:
# Database Definition
# --------------------------------------------------------
# Definition of your database. Format is
# field_name => ['position', 'field_type', 'form-length', 'maxlength', 'not_null', 'default', 'valid_expr']

%db_def = (
ID => [0, 'numer', -2, 8, 1, '', ''],
Name => [1, 'alpha', 40, 255, 1, '', ''],
'Email Address' => [2, 'alpha', 40, 255, 1, '', ''],
'Type of Applicant' => [3, 'alpha', 0, 60, 1, '', ''],
'Interview Date' => [4, 'date', 12, 15, 1, &get_date, ''],
University => [5, 'alpha', 0, 255, 1, '', ''],
'Number of Interviewers' => [6, 'alpha', 0, 60, 1, '', ''],
'Who where the interviewers?' => [7, 'alpha', '45x3', 500, 0, '', ''],
'Questions Asked' => [8, 'alpha', '45x20', 50000, 0, '', ''],
'Essay Question (if applicable)' => [9, 'alpha', '45x3', 500, 0, '', ''],
'Outcome of Interview' => [10, 'alpha', 0, 60, 1, '', ''],
'Advice to any future applicant interviewing at this school?' => [11, 'alpha', '45x3', 500, 0, '', ''],
'Any other comments?' => [12, 'alpha', '45x3', 500, 0, '', ''],
Userid => [13, 'alpha', -2, 15, 0, '', '']
);

# The column name for the database key. Can be any column, but it must be unique!
# You can't have two records with the same key value!
$db_key = 'ID';
# Track the key? Should DBMan keep a counter of the next key to use? This isn't
# neccessary if you can guarantee that your entry in the key field will be unique
# (i.e. a userid).
$db_key_track = 1;
# Database delimeter.
$db_delim = '|';
# Use file locking (1 = Yes, 0 = No). Should be used, but won't work on Win95.
$db_use_flock = 1;
# Auto generate the html forms (1 = Yes, 0 = No).
$db_auto_generate = 0;
# Display Benchmarking Information (1 = Yes, 0 = No).
$db_benchmark = 1;
# Display Debugging Information (1 = Yes, 0 = No).
$db_debug = 0;

# Select fields. Field name => 'comma seperated list of drop down options'.
%db_select_fields = (
'Type of Applicant' => 'Sixth form or college student,Graduate student,Student on gap year,International student,Other',
University => 'University of Aberdeen,Queen`s University of Belfast,University of Birmingham,University of Bristol,University of Cambridge,University of Dundee,University of Edinburgh,University of Glasgow,University of Leeds,University of Leicester,University of Liverpool,University of Machester,University of Newcastle,University of Nottingham,University of Oxford,University of St Andrews,University of Sheffield,University of Southampton,University of Wales Cardiff,Guy`s King`s and St Thomas`,Imperial College School of Medicine,University College London UCL,St Bartholomew`s and the Royal QMW, St George`s Hospital Medical School',
'Number of Interviewers' => 'One,Two,Three,Four,Five,More than five',
'Outcome of Interview' => 'Offer - AAA,Offer - AAB,Offer - ABB,Offer - Unconditional,Offer - Other,Rejected,Do not know yet,Rather not say'
);
And here's the three bits in html.pl (I'm using the short/long mod):

Code:
sub html_record_form {
# --------------------------------------------------------
# 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.
# The values to be displayed are in %rec and should be incorporated
# into your form. You can use &build_select_field, &build_checkbox_field
# and &build_radio_field to generate the respective input boxes. Text and
# Textarea inputs can be inserted as is. If you turn on form auto
# generation, the program will build the forms for you (all though they may
# not be as nice). See the README for more info.

my (%rec) = @_;
($db_auto_generate and print &build_html_record_form(%rec) and return);

my $font = 'font face="Trebuchet MS, Verdana, Arial, Helvetica" size=1 color=#CFCEBC';

print qq|
<TABLE WIDTH="100%" CELLPADDING=3 CELLSPACING=0 BORDER=1 BGCOLOR="#29317B" bordercolor="#33579B">
<INPUT TYPE="hidden" NAME="ID" VALUE="$rec{'ID'}" SIZE="3" MAXLENGTH="3">
<TR><TD ALIGN="Right" VALIGN="TOP"><$font>Name: </FONT></TD>
<TD VALIGN="TOP"> <INPUT TYPE="TEXT" NAME="Name" VALUE="$rec{'Name'}" SIZE="40" MAXLENGTH="255"></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font>Email Address: </FONT></TD>
<TD VALIGN="TOP"> <INPUT TYPE="TEXT" NAME="Email Address" VALUE="$rec{'Email Address'}" SIZE="40" MAXLENGTH="255"></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font>Type of Applicant: </FONT></TD>
<TD VALIGN="TOP"> |; print &build_select_field ("Type of Applicant", "$rec{'Type of Applicant'}"); print qq|</TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font>Interview Date: </FONT></TD>
<TD VALIGN="TOP"> <INPUT TYPE="TEXT" NAME="Interview Date" VALUE="$rec{'Interview Date'}" SIZE="12" MAXLENGTH="15"></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font>University: </FONT></TD>
<TD VALIGN="TOP"> |; print &build_select_field ("University", "$rec{'University'}"); print qq|</TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font>Number of Interviewers: </FONT></TD>
<TD VALIGN="TOP"> |; print &build_select_field ("Number of Interviewers", "$rec{'Number of Interviewers'}"); print qq|</TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font>Who where the interviewers?</FONT></TD>
<TD VALIGN="TOP"> <TEXTAREA NAME="Who where the interviewers?" ROWS="3" COLS="40" WRAP="VIRTUAL" MAXLENGTH="255">$rec{'Who where the interviewers?'}</TEXTAREA></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font>Questions Asked:
<font size="1"><i>Hit "Enter" twice after every question!</i></font></TD>
<TD VALIGN="TOP"> <TEXTAREA NAME="Questions Asked" ROWS="20" COLS="40" WRAP="VIRTUAL" MAXLENGTH="255">$rec{'Questions Asked'}</TEXTAREA></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font>Essay Question (if applicable): </FONT></TD>
<TD VALIGN="TOP"> <TEXTAREA NAME="Essay Question (if applicable)" ROWS="3" COLS="40" WRAP="VIRTUAL" MAXLENGTH="255">$rec{'Essay Question (if applicable)'}</TEXTAREA></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font>Outcome of Interview: </FONT></TD>
<TD VALIGN="TOP"> |; print &build_select_field ("Outcome of Interview", "$rec{'Outcome of Interview'}"); print qq|</TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font>What other advice can you offer any future applicant interviewing at this school? </FONT></TD>
<TD VALIGN="TOP"> <TEXTAREA NAME="Advice to any future applicant interviewing at this school?" ROWS="6" COLS="40" WRAP="VIRTUAL" MAXLENGTH="255">$rec{'Advice to any future applicant interviewing at this school?'}</TEXTAREA></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font>Any other comments? </FONT></TD>
<TD VALIGN="TOP"> <TEXTAREA NAME="Any other comments?" ROWS="6" COLS="40" WRAP="VIRTUAL" MAXLENGTH="255">$rec{'Any other comments?'}</TEXTAREA></TD></TR>

</TABLE>
|;
}
---

Code:
# <-- Start of short display formatting -- >

print qq|

<TABLE WIDTH="100%" CELLPADDING=3 CELLSPACING=0 BORDER=1 BGCOLOR="#29317B" bordercolor="#33579B">
<TR><TD ALIGN="Right" VALIGN="TOP" width="80">$site_font1 Name: </FONT></TD>
<TD> $site_font2 $rec{'Name'}</font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP" width="80">$site_font1 Type of Applicant: </FONT></TD>
<TD> $site_font2 $rec{'Type of Applicant'}</TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP" width="80">$site_font1 Interview Date: </FONT></TD>
<TD> $site_font2 $rec{'Interview Date'}</font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP" width="80">$site_font1 University: </FONT></TD>
<TD> $site_font2 $rec{'University'}</font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP" width="80">$site_font1 Questions Asked:</font></TD>
<TD> $site_font2 <a href="$long_url">Click here to view...</a></font></TD></TR>
</TABLE>



|;
---

Code:
# <-- Start of record display -->

my $font = 'font face="Trebuchet MS, Verdana, Arial, Helvetica" size="2" color="#CFCEBC"';

print qq|
<TABLE WIDTH="100%" CELLPADDING=3 CELLSPACING=0 BORDER=1 BGCOLOR="#29317B" bordercolor="#33579B">
<TR><TD ALIGN="Right" VALIGN="TOP">$site_font1 Name: </font></TD>
<TD> <$font>$rec{'Name'}</font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP">$site_font1 Email Address: </font></TD>
<TD> <$font><A HREF="mailto:$rec{'Email Address'}">$rec{'Email Address'}</a></font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP">$site_font1 Type of Applicant: </font></TD>
<TD> <$font>$rec{'Type of Applicant'}</font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP">$site_font1 Interview Date: </font></TD>
<TD> <$font>$rec{'Interview Date'}</font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP">$site_font1 University: </font></TD>
<TD> <$font>$rec{'University'}</font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP">$site_font1 Number of Interviewers: </font></TD>
<TD> <$font>$rec{'Number of Interviewers'}</font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP">$site_font1 Who where the interviewers?</font></TD>
<TD> <$font>$rec{'Who where the interviewers?'}</font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP">$site_font1 Questions Asked:</font></TD>
<TD> <$font>$rec{'Questions Asked'}</font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP">$site_font1 Essay Question (if applicable): </font></TD>
<TD> <$font>$rec{'Essay Question (if applicable)'}</font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP">$site_font1 Outcome of Interview: </font></TD>
<TD> <$font>$rec{'Outcome of Interview'}</font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP">$site_font1 What other advice can you offer any future applicant interviewing at this school? </font></TD>
<TD> <$font>$rec{'Advice to any future applicant interviewing at this school?'}</font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP">$site_font1 Any other comments? </font></TD>
<TD> <$font>$rec{'Any other comments?'}</font></TD></TR>

</TABLE>
|;
Whatever I do, the userid keeps getting displayed in the "Essay Question" field.

Any ideas?

You can take a look, and experiment with, the whole thing at http://www.medstudentuk.com/cgi-bin/iqd/db.cgi.

Thanks,


Saleel Majeed
saleel@medstudentuk.com
http://www.medstudentuk.com/
Quote Reply
Re: Userid keeps popping up! In reply to
Have a read of this: http://www.gossamer-threads.com/scripts/resources/Detailed/1034.html

----
This is due to your having the $auth_user_field variable set incorrectly in your .cfg file. If you have a userid field in your database, set the $auth_user_field to the number of that field. If you do not have a userid field in your database, set the $auth_user_field to -1.

Quote Reply
Re: Userid keeps popping up! In reply to
Thanks Philip (and Brendan) for that - solved the problem straight away.

Must have missed the rather obvious comment in the .cfg file. Blush


Saleel Majeed
saleel@medstudentuk.com
http://www.medstudentuk.com/