##################################################################### # Preview Record # # by JPDeni # # Last modified: 20 May 2000 # ##################################################################### # This mod allows users to preview their records before the records # are added to the database. # In db.cgi, in the midst of all the "elsif" statements in sub main, # add elsif ($in{'preview_record'}) { if ($per_add) { &preview_record; } else { &html_unauth; } } # Add a new subroutine to db.cgi. (I put it just after sub add_record, # but you can put it anywhere, as long as it isn't within another # subroutine. sub preview_record { # -------------------------------------------------------- my ($status, $counter); # Set the userid to the logged in user. ($auth_user_field >= 0) and ($in{$db_cols[$auth_user_field]} = $db_userid); # First we validate the record to make sure the addition is ok. $status = &validate_record; # We keep checking for the next available key, or until we've tried 50 times # after which we give up. while ($status eq "duplicate key error" and $db_key_track) { return "duplicate key error" if ($counter++ > 50); $in{$db_key}++; $status = &validate_record; } if ($status eq "ok") { &html_preview; } else { &html_add_failure($status); } } # In html_add_form (html.pl) change # to # Add a new subroutine. I put it just after html_add_form. sub html_preview { # -------------------------------------------------------- &html_print_headers; print qq| $html_title: Record Preview.
$html_title: Record Preview

<$font_title>Record Preview

<$font>

This is your record as you entered it. If you are satisfied with it, use the "Add it!" button directly below the record. Otherwise, make the changes in the form and use the "Preview Record" button below the form.: |; &html_record(%in); print qq|


|; &html_record_form (%in); print qq|

|; &html_footer; print qq|
|; } # In html_add_failure, change # to