Hello , I am creating a front end to manage the tables.Here is my problem.I send data across as hidden fields.The forward path works fine.but when i click on go back to previous page and choose a different option, it actually remember the previous values.I have no clue why..could anyone help by looking into my code?
#!/usr/bin/perl use DBI; use CGI qw(:standard); # indicates that this +program requires CGI module to run,to load it use CGI::Session ( '-ip_match' ); print "Content-type:text/html\n"; # prints the html header fo +r the page based on login print "Pragma: no-cache", "\n\n"; my $cgi=CGI->new(); $sid = param("session_id"); $usr=param("uid"); $lgn=param("login"); if ($lgn == 1){ print $cgi->start_html( -title => "Main Menu", -bgcolor=> "#003399", ); print "<font color=\"#FFFDCC\"><CENTER> <CENTER> <h1>Company</h1><br>< +hr><br><br><br>"; print $cgi-> start_form({ ## starts a new form that would call ad +dusr.pl -action => "alterDSDB.pl", -method => "POST", }); &hidden_fields(); print $cgi->hidden( -name => "type", -value => "PDF" ); print $cgi->submit({ -name => "alterDSDB", -value => "Alter PDF", }); print $cgi->end_form(); print "<br>"; print $cgi-> start_form({ ## starts a new form that would call ad +dusr.pl -action => "alterDSDB.pl", -method => "POST", }); &hidden_fields(); print $cgi->hidden( -name => "type", -value => "ASCII" ); print $cgi->submit({ -name => "alterDSDBA", -value => "Alter ASCII", }); print $cgi->end_form(); print "<br>"; if ($usr eq "admin"){ #-------------------------------# print $cgi-> start_form({ ## starts a new form that would call ad +dusr.pl -action => "alterDSDBUSR.pl", -method => "POST", }); &hidden_fields(); print $cgi->submit({ -name => "alterDSDBUSR", -value => " Manage Users ", }); print $cgi->end_form(); print "<br>"; } #-------------------------------# print $cgi-> start_form({ ## starts a new form that would call ad +dusr.pl -action => "logout.pl", -method => "POST", }); &hidden_fields(); print $cgi->submit({ -name => "logoutDSDB", -value => " Logout ", }); print $cgi->end_form(); #-------------------------------# print "<br><br><br><hr> Please wait .Don\'t use the browser\'s buttons + to move back and forth.</CENTER><br>"; print $cgi->end_html(); } else { print $cgi->start_html( -title => "Main Menu", -bgcolor=> "#003399", ); print "<font color=\"#FFFDCC\"><CENTER> <CENTER> <h1> Company</h1><br> +<hr><br><br><br>"; print "<h2> You are not logged in.Session expired.<br>Log in again</h2 +><br>"; $sid = undef; $uid = undef; $lgn = undef; &hidden_fields(); #-------------------------------# print $cgi-> start_form({ ## starts a new form that would call ad +dusr.pl -action => "loginDb.pl", -method => "POST", }); &hidden_fields(); print $cgi->submit({ -name => "Login", -value => "Go to Login Page", }); print $cgi->end_form(); print "<br><br><br><hr> Please wait .Don\'t use the browser\'s buttons + to move back and forth.</CENTER><br>"; print $cgi->end_html(); } sub hidden_fields(){ print $cgi->hidden( -name => "session_id", -value => $sid ); print $cgi->hidden( -name => "uid", -value => $authuser ); print $cgi->hidden( -name => "login", -value => 1 ); } sub hidden_fields(){ print $cgi->hidden( -name => "session_id", -value => $sid ); print $cgi->hidden( -name => "uid", -value => $authuser ); print $cgi->hidden( -name => "login", -value => 1 ); }
And the second page
#!/usr/bin/perl use DBI; use CGI qw(:standard); # indicates that this +program requires CGI module to run,to load it use CGI::Session ( '-ip_match' ); print "Content-type:text/html\n"; # prints the html header fo +r the page based on login print "Pragma:no-cache", "\n\n"; #$session = CGI::Session->load(); my $cgi=CGI->new(); #my $lgn=$session->param("user"); #print "user : $lgn\n"; $sid = param("session_id"); $usr=param("uid"); $lgn=param("login"); $type=param("type"); #print "Login :$lgn\t$usr\n"; if ($lgn == 1){ print $cgi->start_html( -title => "Main Menu", -bgcolor=> "#003399", #-cookie=> $cookie ); print "<font color=\"#FFFDCC\"><CENTER> <CENTER> <h1> Company</h1><br> +<hr><br>"; print "$type<br>"; print $cgi->start_form( -method =>"post", -action =>"doinsertdsdb.pl" ); print $cgi->hidden( -name => "type", -value => $type ); &hidden_fields(); print "<br>"; print $cgi->submit( -name => "Submit", -value =>"Insert" ); print $cgi->end_form(); print $cgi->start_form( -method =>"post", -action =>"dodeletedsdb.pl" ); print $cgi->hidden( -name => "type", -value => $type ); &hidden_fields(); print "<br>"; print $cgi->submit( -name => "Submit", -value =>"Delete" ); print $cgi->end_form(); print $cgi->start_form( -method =>"post", -action =>"doupdatedsdb.pl" ); print $cgi->hidden( -name => "type", -value => $type ); &hidden_fields(); print "<br>"; print $cgi->submit( -name => "Submit", -value =>"Update" ); print $cgi->end_form(); print $cgi->start_form( -method =>"post", -action =>"dsdb_menu.pl" ); print $cgi->hidden( -name => "type", -value => "" ); &hidden_fields(); print "<br>"; print $cgi->submit( -name => "Submit", -value =>"Back to Main Menu" ); print $cgi->end_form(); print "<br><br><br><hr>Don\'t use the browser\'s buttons to move back +and forth.</CENTER><br>"; print $cgi->end_html(); } else{ print $cgi->start_html( -title => "Main Menu", -bgcolor=> "#003399", #-cookie=> $cookie ); print "<font color=\"#FFFDCC\"><CENTER> <CENTER> <h1> Company </h1><br +><hr><br><br><br>"; print "<h2> You are not logged in.Session expired.<br>Log in again</h2 +><br>"; $sid = undef; $uid = undef; $lgn = undef; &hidden_fields(); #-------------------------------# print $cgi-> start_form({ ## starts a new form that would call ad +dusr.pl -action => "loginDb.pl", -method => "POST", }); &hidden_fields(); print $cgi->submit({ -name => "Login", -value => "Go to Login Page", }); print $cgi->end_form(); print "<br><br><br><hr> Please wait .Don\'t use the browser\'s buttons + to move back and forth.</CENTER><br>"; print $cgi->end_html(); } sub hidden_fields(){ print $cgi->hidden( -name => "session_id", -value => $sid ); print $cgi->hidden( -name => "uid", -value => $authuser ); print $cgi->hidden( -name => "login", -value => 1 ); }
Thanks

In reply to perl cgi-pages remember previous entries.How to get over this? by smanicka

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.