Gossamer Forum
Home : Products : DBMan SQL : Discussion :

Userid shows up in form field

Quote Reply
Userid shows up in form field
I am having a slight problem when I add new records to my database. The userid for the logged in user is showing up in the first field on my record form. I have tried several variations in my cfg and html files.

Currently, the .cfg looks like:

_def = (

id => [0, 'INT', -1 '', '', '', '', 0],
qstn_text => [1, 'TEXT', 80,255,'', '', '', 0],
qstn_label_id => [2, 'TEXT', 20,40, '', '', '', 0],
osm2 => [3, 'TEXT', 40, 60, '', '', '', 0],
osm3 => [4, 'TEXT', 40, 60, '', '', '', 0],;


sub html_record looks like:

<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="150"><$font>CSID:</FONT></TD>
<TD VALIGN="TOP" WIDTH="500"> <INPUT TYPE="TEXT" NAME="id" VALUE="$rec{'id'}" SIZE="6" MAXLENGTH="8"></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font>Question Text:</FONT></TD>
<TD VALIGN="TOP">|; print &build_checkbox_field ("qstn_text", "$rec{'qstn_text'}"); print qq|</TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font>Question Label ID: </FONT></TD>
<TD VALIGN="TOP">|; print &build_checkbox_field ("qstn_label_id", "$rec{'qstn_label_id'}"); print qq|</TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font>OSM 2:</FONT></TD>
<TD VALIGN="TOP"> <INPUT TYPE="TEXT" NAME="osm2" VALUE="$rec{'osm2'}" SIZE="40" MAXLENGTH="255"></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font>OSM 3: </FONT></TD>
<TD VALIGN="TOP"> <INPUT TYPE="TEXT" NAME="osm3" VALUE="$rec{'osm3'}" SIZE="40" MAXLENGTH="255"></TD></TR>


and sub html_record looks like:

<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="200"><$font>CSID:</FONT></TD>
<TD VALIGN="TOP" WIDTH="450"> <$font>$rec{'id'}</font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font>Question Text:</FONT></TD>
<TD VALIGN="TOP"> <$font>$rec{'qstn_text'}</font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font>Question Label ID: </FONT></TD>
<TD VALIGN="TOP"> <$font>$rec{'qstn_label_id'}</font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font>OSM 2:</FONT></TD>
<TD VALIGN="TOP"> <$font>$rec{'osm2'}</font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font>OSM 3: </FONT></TD>
<TD VALIGN="TOP"> <$font>$rec{'osm3'}</font></TD></TR>


I have tried putting userid in as field 1 and field 0, and cut and pasted till my fingers bled, and I still get my userid appearing in the "id" field on all the records (actually, it causes the second record entered to be rejected because of a duplicate id.

any suggestions?

Alan Pollenz
Quote Reply
Re: Userid shows up in form field In reply to
There's a little bug in sub add_record -- actually a holdover from the non-SQL version.

Change


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


to


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



You'll need to make the same change in sub modify_record.


JPD
Quote Reply
Re: Userid shows up in form field In reply to
Thanks.

Alan Pollenz