Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need Help with writing to flat file from add_record sub

Status
Not open for further replies.

calabama

Programmer
Feb 19, 2001
180
US
Trying to understand how to write the 'checked'value of
<input type=checkbox name=&quot;presider&quot; value=&quot;&quot; $myvar> while inside of add_record sub.


Thanks

Code:
#####################################
@fields = (&quot;first&quot;,&quot;last&quot;,&quot;position&quot;,&quot;email&quot;,&quot;telephone&quot;,&quot;presider&quot;);

sub add_record {
  $key   = time();
  $record=$key;
  foreach $field (@fields){
       ${$field}  = $q->param($field);
    ${$field}  = filter(${$field});
    $record   .= &quot;\::${$field}&quot;;

                      }

 $record   .= &quot;\::${$presider}&quot;;
print&quot;were inside of add_record sub\n&quot;;
  unless (-e $database){
    open (DB, &quot;>$database&quot;) || die &quot;Error creating database.  $!\n&quot;;
  } else {
    open (DB, &quot;>>$database&quot;) || die &quot;Error opening database.  $!\n&quot;;
  }
   flock DB, $EXCLUSIVE;
   seek DB, 0, 2;
   print DB &quot;$record\n&quot;;
   flock DB, $UNLOCK;
  close(DB);
} # End of add_record subroutine.

########################################3
sub print_add_screen{
  print<<HTML;
   <HTML><HEAD><TITLE>Add a Record</TITLE></HEAD>
    <BODY BGCOLOR=&quot;#FFFFFF&quot;>
     <CENTER><FONT SIZE=5 FACE=&quot;ARIAL&quot;>
      Add a Record
     </FONT></CENTER>
     <P>
     <FORM ACTION=&quot;database.cgi&quot; METHOD=POST>
      <CENTER>



<input type=checkbox name=&quot;presider&quot; value=&quot;&quot; $myvar>   Check here <B>only</B> if individual is currently a presider


<TABLE BORDER=1 CELLSPACING=0>
HTML
  foreach $field (@fields){
       print<<HTML;
        <TR>
         <TD BGCOLOR=&quot;e0e0e0&quot;><B>\u$field:</B></TD>
         <TD><INPUT TYPE=TEXT NAME=&quot;$field&quot;></TD>
        </TR>
HTML
  } # End of foreach.

      print<<HTML;
       <TR>
        <TD COLSPAN=2 BGCOLOR=&quot;e0e0e0&quot;>
         <CENTER>
          <INPUT TYPE=SUBMIT NAME=action VALUE=&quot;Add Record&quot;>
         </CENTER>
        </TD>
       </TR>
      </TABLE></CENTER>
     <P>
    </FONT>
   </BODY></HTML>
HTML
} # End of print_add_screen subroutine.

In the begining
Let us first assume that there was nothing to begin with.
 
shouldn't [tt]$record .= '::'.$q->param('presider');[/tt] work?

jaa
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top