Here is the code, the HTML page that is a template that is merged with the %data hash handled by sub "merge_template" I've even wrote little test pages and scripts just to test the data passing and that is where i discovered the diff between "POST" and "GET"...i will send those too... During the post no data is passed to the cgi....i.e. $cgi->param('PARAM') = nothing !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! test html !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! <html> <head> <title>test</title> </head> <html> <body> <form enctype="multipart/form-data" method="POST" action="/apps/test1/test.cgi"> Select File: <input TYPE="FILE" NAME="FILE_TO_UPLOAD"><br> Favorite color:<input TYPE="TEXT" NAME="FAVCOLOR"><br> <INPUT NAME="SUBMIT" TYPE=SUBMIT VALUE="SUBMIT"> </form> </body> </html> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! test cgi !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! #!/usr/bin/perl use CGI; $cgi = new CGI; $submit = $cgi->param('SUBMIT'); $fh = $cgi->param('FILE_TO_UPLOAD'); $fav = $cgi->param('FAVCOLOR'); open(UPLOAD, ">/tmp/fileuploadtest"); while (<$fh>) { print UPLOAD; } close(UPLOAD); open(LOG, ">/tmp/test.log"); print LOG "$submit\n"; #print LOG "$file\n"; print LOG "$fav\n"; close(LOG); print $cgi->header; print $cgi->start_html; print "$submit<br>"; print "$fh<br>"; print "$fav<br>"; print $cgi->end_html; !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! End test !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! and this is the form header in the REAL HTML doc.... <form enctype="multipart/form-data" method="POST" action="/path/to/contract_v1"> #relative path!! <input TYPE="FILE" NAME="FILE_TO_UPLOAD"> <input type="text" name="CONTACTPHONE1" value="%CONTACTPHONE1%"> many more <inputs> a submit </form> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! THIS IS THE REAL CGI SCRIPT !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! #!/usr/bin/perl ###################################################### # # Contract_v1 # by Chris # ###################################################### use DBI; use CGI; use CGI::Carp; ########################################################## # Global variables ########################################################## $HTML_DIR = '/usr/local/apache/htdocs/contract'; $HTML_URL = '/contract'; $APPS_DIR = '/usr/local/apache/apps/contract'; $APPS_URL = '/contract'; $contract_date = `date +%y%m%d%H%M%S`; $file_tmp = "/usr/local/apache/tmp/contractweb" . $contract_date; #$file_date = "/application_svr/contractweb/contractweb" . $contract_date; $file_date = "/application_svr/contractweb_test/contractweb_test" . $contract_date; chop($file_date); chop($file_tmp); $file_name = $file_date . ".dat"; $file_name_ux = $file_tmp . ".ux"; $file_name_contract = $file_date . ".contractweb"; $file_name_go = $file_date . ".go"; $cgi = new CGI; $db = "Oracle"; $remote_user = $ENV{REMOTE_USER}; $ENV{ORACLE_HOME} = "/usr/local/oracle"; ########################################################## # Global cgi parameters ########################################################## $submit = $cgi->param('SUBMIT'); $lender_name = $cgi->param('LENDER_NAME'); $master_policy = $cgi->param('MASTER_POLICY'); $aplus_master_policy = $cgi->param('APLUS_MASTER_POLICY'); $contactname = $cgi->param('CONTACTNAME'); $contactphone1 = $cgi->param('CONTACTPHONE1'); $contactphone2 = $cgi->param('CONTACTPHONE2'); $contactphone3 = $cgi->param('CONTACTPHONE3'); $contacttelephone = $contactphone1 . $contactphone2 . $contactphone3; $authorizedrep = $cgi->param('AUTHORIZEDREP'); $contactfax1 = $cgi->param('CONTACTFAX1'); $contactfax2 = $cgi->param('CONTACTFAX2'); $contactfax3 = $cgi->param('CONTACTFAX3'); $contactfax = $contactfax1 . $contactfax2 . $contactfax3; $contactemail = $cgi->param('CONTACTEMAIL'); $submission_type1 = $cgi->param('SUBMISSION_TYPE1'); # 1=DU,2=LP 3=MI Only $submission_type2 = $cgi->param('SUBMISSION_TYPE2'); # 1=DU,2=LP 3=MI Only $submission_type3 = $cgi->param('SUBMISSION_TYPE3'); # 1=DU,2=LP 3=MI Only $du_triad_mi = $cgi->param('DU_TRIAD_MI'); # Only one can be chked $lp_triad_mi = $cgi->param('LP_TRIAD_MI'); # "" $credit_bureau = $cgi->param('CREDIT_BUREAU'); $credit_report_ref = $cgi->param('CREDIT_REPORT_REF'); $du_decision_type = $cgi->param('DU_DECISION_TYPE'); $lp_decision_type = $cgi->param('LP_DECISION_TYPE'); $crdt_score_reported = $cgi->param('CRDT_SCORE_REPORTED'); $cb_crdt_score_reported = $cgi->param('CB_CRDT_SCORE_REPORTED'); $mi_sub_type = $cgi->param('MI_SUB_TYPE'); $cov_pct = $cgi->param('COV_PCT'); $prem_type = $cgi->param('PREM_TYPE'); $single_years_type = $cgi->param('SINGLE_YEARS_TYPE'); $rnwl_calc_basis_type = $cgi->param('RNWL_CALC_BASIS_TYPE'); $refundable = $cgi->param('REFUNDABLE'); $lender_paid_flg = $cgi->param('LENDER_PAID_FLG'); $premium_financed = $cgi->param('PREMIUM_FINANCED'); $base_loan_amt = $cgi->param('BASE_LOAN_AMT'); $special_plans = $cgi->param('SPECIAL_PLANS'); $type_of_buydown = $cgi->param('TYPE_OF_BUYDOWN'); $buydown_term = $cgi->param('BUYDOWN_TERM'); $index_type = $cgi->param('INDEX_TYPE'); $mths_to_first_rate_chg = $cgi->param('MTHS_TO_FIRST_RATE_CHG'); $rate_cap_per_adj_pct = $cgi->param('RATE_CAP_PER_ADJ_PCT'); $freq_of_rate_chg = $cgi->param('FREQ_OF_RATE_CHG'); $cap_over_life_of_loan_pct = $cgi->param('CAP_OVER_LIFE_OF_LOAN_PCT'); $county = $cgi->param('COUNTY'); $product_code = $cgi->param('PRODUCT_CODE'); $wholesaler_name = $cgi->param('WHOLESALER_NAME'); $condo_proj_name = $cgi->param('CONDO_PROJ_NAME'); $comment_msg = $cgi->param('COMMENT_MSG'); $property_type = $cgi->param('PROPERTY_TYPE'); $first_payment_date = $cgi->param('FIRST_PAYMENT_DATE'); $secondary_financing_type = $cgi->param('SECONDARY_FINANCING_TYPE'); $secondary_financing_amt = $cgi->param('SECONDARY_FINANCING_AMT'); $sales_concessions_amt = $cgi->param('SALES_CONCESSIONS_AMT'); $document_type_code = $cgi->param('DOCUMENT_TYPE_CODE'); $risk_grade_evaluation = $cgi->param('RISK_GRADE_EVALUATION'); $affordable_product_type = $cgi->param('AFFORDABLE_PRODUCT_TYPE'); $g2refnum = $cgi->param('G2REFNUM'); $lpfile = $cgi->param('LPFILE'); $SAVE_DIRECTORY = "/application_svr/contractweb_test"; $file_to_upload = $cgi->param('FILE_TO_UPLOAD'); $submission_type = submission_type(); ( $aplus_mp_label, $aplus_note_label, $aplus_note ) = aplus_master_policy_val(); $remote_user = $ENV{REMOTE_USER}; %user_info = get_user_info( database_open() ); %mi_user_contact_info = get_mi_user_contact_info( database_open() ); %master_policy_info = et_master_policy_info( database_open_mint(), $user_info{SVR_NO} ); %aplus_master_policy_info = et_aplus_master_policy_info( database_open(), $user_info{SVR_NO} ); ######################################################### # Merge all information hashes into a single hash ######################################################### %data = ( %user_info, %mi_user_contact_info, %master_policy_info, %aplus_master_policy_info ); $data{ACTION} = "$ENV{SCRIPT_NAME}"; $data{CONTACTPHONE1} = substr( $data{CONTACTTELEPHONE}, 0, 3 ); $data{CONTACTPHONE2} = substr( $data{CONTACTTELEPHONE}, 3, 3 ); $data{CONTACTPHONE3} = substr( $data{CONTACTTELEPHONE}, 6, 4 ); $data{CONTACTFAX1} = substr( $data{CONTACTFAX}, 0, 3 ); $data{CONTACTFAX2} = substr( $data{CONTACTFAX}, 3, 3 ); $data{CONTACTFAX3} = substr( $data{CONTACTFAX}, 6, 4 ); open(LOG, ">/tmp/data.log"); for (keys(%data)) { print LOG "Key $_ = $data{$_}\n"; } print LOG "$submit\n"; print LOG "$remote_user\n"; close(LOG); if ( $submit eq "Cancel" ) { my ( $cgi ); $cgi = new CGI $page = submit_eq_cancel( %data ); print $cgi->header; print $page; die "$remote_user has just Canceled Contract Underwirting"; } elsif ( $submit eq '' ) { my ( $cgi ); $cgi = new CGI $page = submit_eq_nothing( %data ); print $cgi->header; print $page; die "$remote_user has just entered Contract Underwirting"; } else { submit_eq_submit( %data ); } close(LOG); ########################################################## # Set and return the database handle ########################################################## sub database_open { my ( $dbh ); $dbh = DBI->connect("dbi:$db:something.something.tgic.com", "something", "something") or die "Cannot connect to database: $DBI::errstr"; return ( $dbh ); } ########################################################### # Set and return the MINT database handle ########################################################### sub database_open_mint { my ( $dbh_mint ); $dbh_mint = DBI->connect("dbi:$db:something.something.tgic.com", "something", "something") or die "Cannot connect to MINT database: $DBI::errstr"; return ( $dbh_mint ); } ########################################################## # Get the users contact info from the MI_USER_CONTACT_TBL table ########################################################## sub get_mi_user_contact_info { my ( $dbh ) = @_; $sth = $dbh->prepare( "SELECT * from MI_USER_CONTACT_TBL where USER_NAME = '$remote_user'" ) or die "Cannot prepare get_mi_user_contact_info SQL: $DBI::errstr"; $sth->execute or die "Cannot execute get_mi_user_contact_info SQL: $DBI::errstr"; $row = $sth->fetchrow_hashref; return ( %$row ); } ########################################################## # Get the users info from the USER_TBL table ########################################################## sub get_user_info { my ( $dbh ) = @_; $sth = $dbh->prepare( "SELECT * from USER_TBL where USER_NAME = '$remote_user'" ) or die "Cannot prepare get_user_info SQL: $DBI::errstr"; $sth->execute or die "Cannot execute get_user_info SQL: $DBI::errstr"; $row = $sth->fetchrow_hashref; return ( %$row ); } ########################################################## # Check to see if it's the users first time here, if so then make them read the disclaimer and accept it ########################################################## sub if_my_first_time { my ( $first_time ) = @_; if ( $first_time eq '' ) { print $cgi->redirect('https://extranet.tgic.com/apps/contract/contract_disclaimer. cgi'); } else { #print $cgi->redirect('https://extranet.tgic.com/apps/contract/contract_v1'); print $cgi->redirect('https://extranet.tgic.com/apps/test1/contract_v1'); die("New contract session for $remote_user"); } } ########################################################## # Get the master policy info from MP_HOLDERS table in MINT ########################################################## sub get_master_policy_info { my ( $dbh_mint, $svr_no ) = @_; my ( $sth, $data ); $sth = $dbh_mint->prepare("SELECT MPH_ID MASTER_POLICY, RTRIM(NAME) LENDER_NAME FROM MP_HOLDERS WHERE MPH_ID = '$svr_n o' AND MPH_TYPE <> 'HO' ORDER BY MPH_TYPE") or die "Cannot prepare get_master_policy_info SQL: $DBI::errstr"; $sth->execute or die "Cannot execute get_master_policy_info SQL: $DBI::errstr";; $data = $sth->fetchrow_hashref; $sth->finish; return ( %$data ); } ########################################################## # Get the APLUS master policy info from MI_APLUS_TBL table ########################################################## sub get_aplus_master_policy_info { my ( $dbh, $svr_no ) = @_; my ( $sth, $row ); $sth = $dbh->prepare("SELECT APLUS_MASTER_POLICY from MI_APLUS_TBL where REGULAR_MASTER_POLICY = '$svr_no'" ) or die "Cannot prepare get_aplus_master_policy_info SQL: $DBI::errstr"; $sth->execute or die "Cannot execute get_aplus_master_policy_info SQL: $DBI::errstr"; $row = $sth->fetchrow_hashref; return ( %$row ); } ########################################################## # Merge all data with the template ########################################################## sub merge_template { my ( $template, %data ) = @_; my ( $tmpl,@tmpl ); open(TMPL, "$template") or die "Can't open $template"; @tmpl = <TMPL>; close(TMPL); $tmpl = join('', @tmpl); for(keys(%data)) { $tmpl =~ s/%$_%/$data{$_}/g; } $tmpl =~ s/\.checked \= %(.*)%/\.checked \= 0/g; $tmpl =~ s/\[%(.*)%\]/\[0\]/g; $tmpl =~ s/%([A-Z].*)%//g; return $tmpl; } ########################################################## # Update the FIRST_TIME value in USER_TBL after the user has accepted the agreement ########################################################## sub setdisclaimer { my ( $dbh, $val ) = @_; $sth = $dbh->prepare("UPDATE user_tbl SET first_time=$val, mi_date_accepted=SYSDATE WHERE user_name = '$user_info{USER_NAME}'") or die "Cannot prepare setdisclaimer SQL: $DBI::errstr"; $sth->execute or die "Cannot execute setdisclaimer SQL: $DBI::errstr"; } ########################################################## # Set and return master policy values ########################################################## sub aplus_master_policy_val { if ( $aplus_master_policy ne '') { $aplus_mp_label = 'APLUS MP#:'; $aplus_note_label = 'Note:'; $aplus_note = 'May qualify for APLUS'; } else { $aplus_mp_label = ''; $aplus_note_label = ''; $aplus_note = ''; } return ( $aplus_mp_label, $aplus_note_label, $aplus_note ); } ########################################################## # Set the submission_type ########################################################## sub submission_type { my ( $submission_type ) = 0; if ($submission_type1 == 1 && $du_triad_mi != 1) { $submission_type = 1; } elsif ($submission_type1 == 1 && $du_triad_mi == 1) { $submission_type = 2; } elsif ($submission_type2 == 2 && $lp_triad_mi != 1) { $submission_type = 3; } elsif ($submission_type2 == 2 && $lp_triad_mi == 1) { $submission_type = 4; } elsif ($submission_type3 == 3) { $submission_type = 5; } else { $submission_type = 0; } return ( $submission_type ); } ########################################################## # Here, if the value of $submit is "Cancel" it means that the user has canceled the previous action. # And take them to the right page, with all the %data. ########################################################## sub submit_eq_cancel { my ( %data ) = @_; my ( $page ); undef $submit; $page = merge_template("$HTML_DIR/contract_v1.html",%data); return ( $page ); } ########################################################## # Here, if the value of $submit is nothing it means that this is the first time the user has entered for # this session. And take them to the right page, with all the %data. ########################################################## sub submit_eq_nothing { my ( %data ) = @_; my ( $page ); undef $submit; $page = merge_template("$HTML_DIR/contract_v1_test.html",%data); return ( $page ); } ########################################################## # Here, if the value of $submit is "submit" it means that the user has entered data on the application # and is ready to submit the information. Here all the information is processed. ########################################################## sub submit_eq_submit { my ( %data ) = @_; my $dbh = database_open(); if ($submit eq 'Submit') { undef $submit; if ($dufile ne '') { print $cgi->header(); $page = merge_template("$HTML_DIR/contract_dufile_error.html",%data); print $page; } else { $query = sprintf('BEGIN contract_pkg.contact_update_insert (:bind1, :bind2, :bind3, :bind4, :bind5, :bind6, :rc); END;'); $sth = $dbh->prepare($query); $sth->bind_param_inout(":bind1", \$ENV{REMOTE_USER}, 32); $sth->bind_param_inout(":bind2", \$contactname, 30); $sth->bind_param_inout(":bind3", \$contacttelephone, 15); $sth->bind_param_inout(":bind4", \$contactfax, 15); $sth->bind_param_inout(":bind5", \$contactemail, 80); $sth->bind_param_inout(":bind6", \$authorizedrep, 80); $sth->bind_param_inout(":rc", \$rc, 1); $sth->execute || print $dbh->errstr; $sth->finish; if ($remote_user eq 'something') #used for testing { open(UPLOADFILE, ">$file_name_ux"); if ($file_to_upload =~ /([^\/\\]+)$/) { $Filename = $1; $Filename =~ s/^\.+//; $File_Handle = $file_to_upload; } undef $BytesRead; undef $Buffer; while ($Bytes = read($File_Handle,$Buffer,1024)) { $BytesRead += $Bytes; print UPLOADFILE $Buffer; } $TOTAL_BYTES += $BytesRead; close($File_Handle); if ($TOTAL_BYTES eq 0) { print $cgi->header(); $page = merge_template("$HTML_DIR/contract_dufile_error.html",%data); print $page; die ("Contract Error - Selected File has no data"); } close(UPLOADFILE); system("to_dos", $file_name_ux, $file_name); $data{CONTACTEMAIL} = $contactemail; print $cgi->header(); $page = merge_template("$HTML_DIR/contract_acknowledgement.html",%data); print $page; die "At the end"; } else { unless (open ENTRYLOGFILE, "> " . "$file_name_ux") { printf TESTLOGFILE "Unable to open unix file named %s\n", $file_name_ux; } else { printf TESTLOGFILE "Opened the unix file named %s successfully\n", $file_name_ux; } printf ENTRYLOGFILE "ZZZ%-35.35s%-10.10s%-10.10s%-10.10s%-35.35s%-10.10s%-35.35s%-10.10s%-35.3 5s%-1.1s%-35.35s%-25.25s%-20.20s%-20.20s%-3.3s%-3.3s%-10.10s%-5.5s%-15.15s%- 5.5s%-20.20s%-15.15s%-10.10s%-1.1s%-10.10s%-25.25s %-10.10s%-10.10s%-15.15s%-3.3s%-6.6s%-3.3s%-6.6s%-20.20s%-30.30s%-40.40s%-30 .30s%-256.256s%-20.20s%-8.8s%-25.25s%-12.12s%-12.1 2s%-20.20s%-1.1s%-40.40s%-5.5s%-21.21s\n", $lender_name, $master_policy, $aplus_mp_label, $aplus_master_policy, $contactname, $contacttelephone, $authorizedrep, $contactfax, $contactemail, $submission_type, $credit_bureau, $credit_report_ref, $du_decision_type, $lp_decision_type, $crdt_score_reported, $cb_crdt_score_reported, $mi_sub_type, $cov_pct, $prem_type, $single_years_type, $rnwl_calc_basis_type, $refundable, $lender_paid_flg, $premium_financed, $base_loan_amt, $special_plans, $type_of_buydown, $buydown_term, $index_type, $mths_to_first_rate_chg, $rate_cap_per_adj_pct, $freq_of_rate_chg, $cap_over_life_of_loan_pct, $county, $product_code, $wholesaler_name, $condo_proj_name, $comment_msg, $property_type, $first_payment_date, $secondary_financing_type, $secondary_financing_amt, $sales_concessions_amt, $document_type_code, $risk_grade_evaluation, $affordable_product_type, $aplus_note_label, $aplus_note; if ($file_to_upload =~ /([^\/\\]+)$/) { $Filename = $1; $Filename =~ s/^\.+//; $File_Handle = $file_to_upload; } undef $BytesRead; undef $Buffer; while ($Bytes = read($File_Handle,$Buffer,1024)) { $BytesRead += $Bytes; print ENTRYLOGFILE $Buffer; } $TOTAL_BYTES += $BytesRead; close($File_Handle); if ($TOTAL_BYTES eq 0) { print $cgi->header(); merge_template("$HTML_DIR/contract_dufile_error.html",%data); die ("Contract Error - Selected File has no data"); } system("to_dos", $file_name_ux, $file_name); if ($TOTAL_BYTES eq 0) { print $cgi->header(); merge_template("$HTML_DIR/contract_dufile_error.html",%data); die ("Contract Error - Selected File has no data"); } system("to_dos", $file_name_ux, $file_name); open ENTRYLOGFILE_GO, "> " . "$file_name_go"; close(ENTRYLOGFILE_GO); $data{CONTACTEMAIL} = $contactemail; print $cgi->header(); $page = merge_template("$HTML_DIR/contract_acknowledgement.html",%data); print $page; } } } } ########################################################## # Test ########################################################## sub test { my ( %data ) = @_; print $cgi->header(); print $cgi->start_html(); for (keys(%data)) { print "The keys is <b>$_</b>, and the value is <b>$data{$_}</b><br>"; } print "$data{APLUS_MASTER_POLICY}"; print $cgi->end_html(); } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]