Hello and thanks for taking a look at this!

I am a new perl programmer using CGI.pm to create my application.

I have a subroutine defaultNewInvest() that creates a form that users can input some data. (The form has been truncated.) I would like to be able to search the database and retrieve the information INTO THE SAME FORM so that changes can be made.

I have no trouble creating the form, inserting the data into an Oracle database, nor retrieving the names into a list. If I click on the name, I would like to be taken back to the original form with the information filled in.

How do I query the database and pass all the information to defaultNewInvest() so that the information that is currently in the database can be viewed and/or edited???

I have searched the web and can not find any examples of this. I have seen HTML::Template but did not know if that was the best was to proceed. If anything is not clear, please ask. I am desperate for a solution.

Thanks in advance. I am including the code for creating my form. Maybe that will help in figuring out what I am not understanding.

PS. I have not included all hte subroutines. I merely included the if-elsif-else structure so that one can see the flow. Thanks again.

#!c:/perl/bin/perl.exe -w use strict; use DBI; use CGI; use vars qw($CGI $DBH $dbsource $schema $user $psswd $DEBUG $cookie); ($dbsource, $schema, $user, $psswd) = ($ENV{DB_SOURCE}, $ENV{SCHEMA}, +$ENV{USER}, $ENV{PSSWD}); $CGI = new CGI; $DBH=DBI->connect($dbsource,$user,$psswd,{RaiseError =>1, AutoCommit = +>0}) || die "Database connection not made: $DBI::errstr"; if ( $CGI->param("saveNewInvestBtn") ) { insertNewInvestigator($CGI, $DBH); } elsif ( $CGI->param("peopleSearchBtn") ) { peopleSearchResults($CGI, $DBH); } elsif ($CGI->param("keywords") eq "newInvest" ) { defaultNewInvestigator($CGI); } else { mainPage($CGI); } sub defaultNewInvest { my $q = shift; print $q->header(); print $q->start_html(-title=>'Primary Investigator Information'); print $q->h1("Primary Investigator Information"); print $q->start_form(-action=>"investigator.pl", -method=>"post", +-name=>"form1", -onSubmit=>"return checkInvestForm();"); print$q->h3("Address Information"); print $q->table( {-border=>0}, $q->Tr([ $q->td( ["Salutation*:", $q->popup_menu(-name=>"inves +t_salutation", -values=>["Dr.", "Mr.", "Mrs.", "Ms."])."   +Degree:   ".$q->textfield(-name=>"invest_degree")]), $q->td( ["First Name*:", $q->textfield(-name=>"invest +_fname", -size=>40)] ), $q->td( ["Mid. Name:", $q->textfield(-name=>"invest_m +name", -size=>40)]), $q->td( ["Last Name*:", $q->textfield(-name=>"invest_ +lname", -size=>40)] ), $q->td( ["Title:", $q->textfield(-name=>"invest_title +", -size=>40)]) ]) ); print $q->submit( -name=>"saveNewInvestBtn", -value=>"Save", class +=>"buttonstyle" ); print $q->end_form(); print $q->end_html(); }

In reply to Populating a form with data from a DB by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.