Lines 58-71
if ($op eq 'add_form') {
Link Here
|
58 |
#---- if primkey exists, it's a modify action, so read values to modify... |
58 |
#---- if primkey exists, it's a modify action, so read values to modify... |
59 |
my $data; |
59 |
my $data; |
60 |
if ($cityid) { |
60 |
if ($cityid) { |
61 |
my $sth=$dbh->prepare("select cityid,city_name,city_zipcode from cities where cityid=?"); |
61 |
my $sth=$dbh->prepare("select cityid,city_name,city_state,city_zipcode,city_country from cities where cityid=?"); |
62 |
$sth->execute($cityid); |
62 |
$sth->execute($cityid); |
63 |
$data=$sth->fetchrow_hashref; |
63 |
$data=$sth->fetchrow_hashref; |
64 |
} |
64 |
} |
65 |
|
65 |
|
66 |
$template->param( |
66 |
$template->param( |
67 |
city_name => $data->{'city_name'}, |
67 |
city_name => $data->{'city_name'}, |
68 |
city_zipcode => $data->{'city_zipcode'}); |
68 |
city_state => $data->{'city_state'}, |
|
|
69 |
city_zipcode => $data->{'city_zipcode'}, |
70 |
city_country => $data->{'city_country'}); |
69 |
# END $OP eq ADD_FORM |
71 |
# END $OP eq ADD_FORM |
70 |
################## ADD_VALIDATE ################################## |
72 |
################## ADD_VALIDATE ################################## |
71 |
# called by add_form, used to insert/modify data in DB |
73 |
# called by add_form, used to insert/modify data in DB |
Lines 73-84
if ($op eq 'add_form') {
Link Here
|
73 |
my $sth; |
75 |
my $sth; |
74 |
|
76 |
|
75 |
if ($input->param('cityid') ){ |
77 |
if ($input->param('cityid') ){ |
76 |
$sth=$dbh->prepare("UPDATE cities SET city_name=?,city_zipcode=? WHERE cityid=?"); |
78 |
$sth=$dbh->prepare("UPDATE cities SET city_name=?,city_state=?,city_zipcode=?,city_country=? WHERE cityid=?"); |
77 |
$sth->execute($input->param('city_name'),$input->param('city_zipcode'),$input->param('cityid')); |
79 |
$sth->execute($input->param('city_name'),$input->param('city_state'),$input->param('city_zipcode'),$input->param('city_country'),$input->param('cityid')); |
78 |
} |
80 |
} |
79 |
else{ |
81 |
else{ |
80 |
$sth=$dbh->prepare("INSERT INTO cities (city_name,city_zipcode) values (?,?)"); |
82 |
$sth=$dbh->prepare("INSERT INTO cities (city_name,city_state,city_zipcode,city_country) values (?,?,?,?)"); |
81 |
$sth->execute($input->param('city_name'),$input->param('city_zipcode')); |
83 |
$sth->execute($input->param('city_name'),$input->param('city_state'),$input->param('city_zipcode'),$input->param('city_country')); |
82 |
} |
84 |
} |
83 |
print $input->redirect($script_name); |
85 |
print $input->redirect($script_name); |
84 |
exit; |
86 |
exit; |
Lines 86-97
if ($op eq 'add_form') {
Link Here
|
86 |
# called by default form, used to confirm deletion of data in DB |
88 |
# called by default form, used to confirm deletion of data in DB |
87 |
} elsif ($op eq 'delete_confirm') { |
89 |
} elsif ($op eq 'delete_confirm') { |
88 |
$template->param(delete_confirm => 1); |
90 |
$template->param(delete_confirm => 1); |
89 |
my $sth=$dbh->prepare("select cityid,city_name,city_zipcode from cities where cityid=?"); |
91 |
my $sth=$dbh->prepare("select cityid,city_name,city_state,city_zipcode,city_country from cities where cityid=?"); |
90 |
$sth->execute($cityid); |
92 |
$sth->execute($cityid); |
91 |
my $data=$sth->fetchrow_hashref; |
93 |
my $data=$sth->fetchrow_hashref; |
92 |
$template->param( |
94 |
$template->param( |
93 |
city_name => $data->{'city_name'}, |
95 |
city_name => $data->{'city_name'}, |
|
|
96 |
city_state => $data->{'city_state'}, |
94 |
city_zipcode => $data->{'city_zipcode'}, |
97 |
city_zipcode => $data->{'city_zipcode'}, |
|
|
98 |
city_country => $data->{'city_country'}, |
95 |
); |
99 |
); |
96 |
################## DELETE_CONFIRMED ################################## |
100 |
################## DELETE_CONFIRMED ################################## |
97 |
# called by delete_confirm, used to effectively confirm deletion of data in DB |
101 |
# called by delete_confirm, used to effectively confirm deletion of data in DB |