I posted a question a few days ago because I was having trouble with a script that was supposed to send an e-mail and insert a record into a database within the same script. Because I haven't been able to fix it or figure it out, I decided that I was going to just pass the values of the first form to hidden inputs in my first script, send my e-mail, and then redirect to a second script where I would grab the values of the hidden inputs from the first script and insert them into the DB. For some reason, I am unable to get the values of the hidden fields passed. When I try and print a variable I should have gotten for that form, I get nothing. Can anyone see what I'm doing wrong?? The first script (the "hidden2" at the hidden inputs are intended just for this post, so that my code will show up):
#!/usr/local/bin/perl5.005 use lib '../lib'; use strict; use CGI qw(:standard); my $query = new CGI; #Grab the evaluation responses from the form my $cdsid = $query->param('cdsid'); my $title = $query->param('Title'); my $author = $query->param('Author'); my $book_review = $query->param('book_review'); my $post_review = $query->param('post_review'); my $use_name = $query->param('use_name'); my $sendmail = '/usr/lib/sendmail'; my $recipient = 'mbelang3@ford.com'; my $sender = 'e-Books Feedback <plskills@ford.com>'; my $site_name = 'e-Courses'; my $site_url = '../e-course.html'; my $site_name2 = 'e-Books'; my $site_url2 = '../e-books.html'; my $value; my $field; my $email; my $name; my $mail_body = ''; print "Content-type: text/html\n\n"; print <<"eof"; <input type=hidden2 name="cdsid" value="$cdsid"> <input type=hidden2 name="title" value="$title"> <input type=hidden2 name="author" value="$author"> <input type=hidden2 name="book_review" value="$book_review"> <input type=hidden2 name="post_review" value="$post_review"> <input type=hidden2 name="use_name" value="$use_name"> eof foreach $field (sort ($query->param)) { foreach $value ($query->param($field)) { $mail_body .= "$field: $value\n"; } } if (($email = $query->param('07_email')) and ($query->param('07_email') =~ /@/)) { if ($name = $query->param('cdsid')) { $name =~ s/"//g; $sender = "\"$name\" <$email>"; } else { $sender = "$email"; } } open(MAIL, "|$sendmail -oi -t") or die "Can't open pipe to $sendmail: +$!\n"; print MAIL "To: $recipient\n"; print MAIL "From: $sender\n"; print MAIL "Subject: e-Books Feedback\n\n"; print MAIL "$mail_body"; close(MAIL) or die "Can't close pipe to $sendmail: $!\n"; print "<html><body>" "<script language='JavaScript'>". "window.location='http://wwwdev.pl.ford.com/L2e/cgi-bin/ebo +ok_insert_2.cgi'". "</script></body></html>"; </pre> Which sends you to the second script: <pre> #!/usr/local/bin/perl5.005 use lib '../lib'; use DBI(0.90); use strict; use Database; use CGI qw(:standard); Database::->db_info_path("../lib/db.cfg"); my $dbh = new Database; #Grab the evaluation responses from the form my $cdsid = param('cdsid'); my $title = param('title'); my $author = param('author'); my $book_review = param('book_review'); my $post_review = param('post_review'); my $use_name = param('use_name'); print "Content-type: text/html\n\n"; #Declare variables for insertion constants my $plselect = "u"; my $updt = "L2e Init"; #Insert the e-Book review and book information into il2e009_bk_review if ($book_review) { my %review = ('il2e009_book_title_x' => $title, 'il2e009_book_author_x' => $author, 'il2e009_eval_cds_id_c' => $cdsid, 'il2e009_pl_select_f' => $plselect, 'il2e009_post_rev_f' => $post_review, 'il2e009_post_name_f' => $use_name, 'il2e009_review_x' => $book_review, 'il2e009_last_updt_c' => $updt ); foreach my $key (keys %review) { print "$key = $review{$key}\n"; } print "Attempting insert....\n"; $dbh->insert_row('il2e009_bk_review',\%review); } print $cdsid; $dbh->disconnect;
HELP! I'm pretty sure it doesn't work because I need to submit the form with the hidden fields rather than just redirect the page. Can I submit that automatically and skip the redirect? I don't want the user to have to click anything, this should happen behind the scenes.

In reply to Trouble passing values through hidden fields 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.