I have successfully created code that generates a popup_menu with the fields
id & name. I would like to retrieve user's selection though by retrieving
the selected id and passing it to functions that update a mysql database
with the use of an Insert and an Update statement.
What is the correct way to retrieve the selected value and pass it to to my
functions?

Thank you, Colette

Here is the code at this point...

#!/usr/bin/perl -w
use CGI qw(:standard);
use strict;
use DBI;
require
'/home/httpd/secure.webhostinglogic.com/cgi-bin/database/mysql/dbfunctions.p
l';

my $mydbi = DBI->connect("DBI:mysql:webhostinglogic","whldb","whl96!pi") or
         die "Could not connect";

###############
# Popup Menus #
###############
my ($adsource_sth,$adsource_ref);
my %adsource_hash=();
my @adsource_array=();
my $adsource_sql="SELECT ADVERTISING_SOURCE_ID,ADVERTISING_SOURCE FROM
ADVERTISING_SOURCE";
$adsource_sth=$mydbi ->prepare (qq{$adsource_sql})||die "unable to prepare
statement ",$adsource_sql," :",$DBI::errstr;
$adsource_sth->execute;
$adsource_ref=$adsource_sth->fetchall_arrayref();
$adsource_sth->finish;

foreach (@{$adsource_ref})
{
   if ($_->[0])
   {
      $adsource_hash{$_->[1]}=$_->[0];
      push (@adsource_array,$_->[1]);
    }
}

my ($actype_sth,$actype_ref);
my %actype_hash=();
my @actype_array=();
my $actype_sql="SELECT ACCOUNT_TYPE_ID,ACCOUNT_TYPE FROM ACCOUNT_TYPE";
$actype_sth=$mydbi ->prepare (qq{$actype_sql})||die "unable to prepare
statement ",$actype_sql," :",$DBI::errstr;
$actype_sth->execute;
$actype_ref=$actype_sth->fetchall_arrayref();
$actype_sth->finish;

foreach (@{$actype_ref})
{
   if ($_->[0])
   {
      $actype_hash{$_->[1]}=$_->[0];
      push (@actype_array,$_->[1]);
   }
}

##############
# Begin HTML #
##############
print header('text/html');
print <<HTML_1;
<HTML>
<HEAD>
<TITLE>Web Hosting Logic DB Interface (Customer)</TITLE>
</HEAD>
<BODY>
<CENTER>
<TABLE>
<FORM name="f" action="" method="post">
<TR><TD COLSPAN=2><H1><CENTER>Web Hosting Logic DB
Interface<BR>(Customer)</CENTER></H1></TD></TR>
<TR><TD>Customer Id:</TD><TD><INPUT TYPE="TEXT" name="customerid"></TD></TR>
<TR><TD>Company Name:</TD><TD><INPUT TYPE="TEXT" name="company"></TD></TR>
<TR><TD>Last Name:</TD><TD><INPUT TYPE="TEXT" name="lastname"></TD></TR>
<TR><TD>First Name:</TD><TD><INPUT TYPE="TEXT" name="firstname"></TD></TR>
<TR><TD>Phone:</TD><TD><INPUT TYPE="TEXT" name="phone"></TD></TR>
<TR><TD>Fax:</TD><TD><INPUT TYPE="TEXT" name="fax"></TD></TR>
<TR><TD>Email:</TD><TD><INPUT TYPE="TEXT" name="email"></TD></TR>
<TR><TD>URL:</TD><TD><INPUT TYPE="TEXT" name="url"></TD></TR>
<TR><TD>Address 1:</TD><TD><INPUT TYPE="TEXT" name="address1"></TD></TR>
<TR><TD>Address 2:</TD><TD><INPUT TYPE="TEXT" name="address2"></TD></TR>
<TR><TD>City:</TD><TD><INPUT TYPE="TEXT" name="city"></TD></TR>
<TR><TD>State:</TD><TD><INPUT TYPE="TEXT" name="state"></TD></TR>
<TR><TD>Zip:</TD><TD><INPUT TYPE="TEXT" name="zip"></TD></TR>
<TR><TD>Country:</TD><TD><INPUT TYPE="TEXT"
name="country"></TD></TR></TD></TR>
<TR><TD>Security Question:</TD><TD><INPUT TYPE="TEXT"
name="securityquestion"></TD></TR>
<TR><TD>Security Answer:</TD><TD><INPUT TYPE="TEXT"
name="securityanswer"></TD></TR>
<TR><TD>Notes:</TD><TD><INPUT TYPE="TEXTAREA" name="notes"></TD></TR>
<TR><TD>Current Customer:</TD><TD><SELECT NAME="currentcustomer">
<OPTION VALUE="0">No</OPTION>
<OPTION VALUE="1">Yes</OPTION>
</SELECT>
<TR><TD>Advertising Source:</TD>
<TD>
HTML_1
print popup_menu(-name=>'adsource',-value=>[EMAIL PROTECTED]);
my $advertisingsourceid=param("adsource");

print <<HTML_2;
</TD></TR>
<TR><TD>Account Type:</TD>
<TD>
HTML_2
print popup_menu(-name=>'actype',-value=>[EMAIL PROTECTED]);
my $accounttypeid=param("actype");

print <<HTML_3;
</TD></TR>
<TR><TD>DateStarted:</TD><TD><INPUT TYPE="TEXT"
name="datestarted"></TD></TR>

<TR><TD>&nbsp</TD></TR>
<TR><TD COLSPAN=2><CENTER>
<INPUT TYPE="submit" NAME="update" VALUE="Update">
<INPUT TYPE="submit" NAME="select" VALUE="View">
</CENTER></TD></TR>

</FORM>
HTML_3

my ($CustomerId) = param("customerid");
my ($Company) = param("company");
my ($LastName) = param("lastname");
my ($FirstName) = param("firstname");
my ($Phone) = param("phone");
my ($Fax) = param("fax");
my ($Email) = param("email");
my ($URL) = param("url");
my ($Address1) = param("address1");
my ($Address2) = param("address2");
my ($City) = param("city");
my ($State) = param("state");
my ($Zip) = param("zip");
my ($Country) = param("country");
my ($SecurityQuestion) = param("securityquestion");
my ($SecurityAnswer) = param("securityanswer");
my ($Notes) = param("notes");
my ($AdvertisingSourceId) = param("advertisingsourceid");
my ($AccountTypeId) = param("accounttypeid");
my ($CurrentCustomer) = param("currentcustomer");
my ($DateStarted) = param("datestarted");

my ($DBInsert) = param("insert");
my ($DBDelete) = param("delete");
my ($DBUpdate) = param("update");
my ($DBSelect) = param("select");

my $result=0;

if ($DBSelect)
{
    my $result = SelectCustomer();
}

if ($DBUpdate)
{

print $AdvertisingSourceId $AccountTypeId;
my $result=
UpdateCustomer($CustomerId,$Company,$LastName,$FirstName,$Phone,$Fax,$Email,
$URL,$Address1,$Address2,$City,$State,$Zip,$Country,$SecurityQuestion,$Secur
ityAnswer,$Notes,$AdvertisingSourceId,$AccountTypeId,$CurrentCustomer,$DateS
tarted);

my $result2= SelectCustomer();
}

print <<END_Page;
</TABLE>
</CENTER>
</BODY>
</HTML>
END_Page




Reply via email to