> Calling sub fetch from within the next subroutine again does not work > either :( I believe the fetch sub does as you ask it to. The problem is you are asking it to return the password of row where f_name = '' and f_surname = '' Try passing the names as hidden fields in the first form to the form in which you want to display the password (and call fetch from there). Also, use CGI::Carp qw( fatalsToBrowser ); Can be a great help when you are learning CGI programming. HTH
"Sven Bentlage" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Hi everyone! > I started learning perl about one month ago. > After havin fun and even getting some scripts running, the fun stopped 3 > days ago. :( > > Having found a problem I am not able to figure out myself, I'm not quite > sure any more what to do. > In my script (see below for excerpt) the user enters his/her > name/surname. by using those the password is retrieved from am mysql DB > via DBI, which is done in a subroutine (&fetch). > It works correct, displays the $password2 as it should. But I could not > yet figure out, how to pass the $password2 on to the next subroutine > (&pageone), which is called from inside an if-construct. > (If I do not use the if-construct, all is displayed on the same page at > the same time....) > > Calling sub fetch from within the next subroutine again does not work > either :( > > If anybody can help me, i would be very grateful since I do not know > howw to solve that problem... > > > Regards, > > John > > > Here's the code > > #!/usr/bin/perl -w > > use CGI qw(param); > use DBI; > use strict; > > ########################### > # Config section > ########################### > > # action > my $action = param('action'); > > #data source name > my $dsn = 'DBI:mysql:etpa:localhost:3306'; > > #user > my $db_user = 'etpup'; > > #pass > my $db_pass = '1234abcd'; > > > #f_name > my $f_name = param('f_name'); > > #f_surname > my $f_surname = param('f_surname'); > > #pass > my $pass = param('password'); > > #etp > my $f_etp = param('f_etp'); > > > > unless ($action){&Online_Database_Search} > elsif (($action eq "pw") and (($f_name eq "") or ($f_surname eq > ""))){&Online_Database_Search} > > my $password2 = &fetch; > &pw; > > > if ($action eq "login"){&pageone} > elsif ($action eq "name"){&search_by_name} > elsif ($action eq "print_name"){&print_name} > elsif ($action eq "etp"){&search_by_etp} > elsif ($action eq "print_etp"){&print_etp} > elsif ($action eq "nation"){&search_by_nation} > elsif ($action eq "print_nation"){&print_nation} > elsif ($action eq "keyword"){&search_by_keyword} > elsif ($action eq "print_keyword"){&print_keyword} > ######################################################################### > # subs > ######################################################################### > > sub pw { > > > > > my $dbh = DBI->connect( $dsn, $db_user, $db_pass ) || die "Can nat > connect to MySQL DB $DBI::errstr\n"; > > my $get_pw = $dbh->prepare( > "select name, surname, password from memberscopy > where name = '$f_name' and surname = '$f_surname' " > ); > > $get_pw->execute(); > > while ( my ( @data ) = $get_pw->fetchrow_array() ) { > > print "Content-type: text/html\n\n"; > > print qq~ > <html> > <head> > <title>Enter password</title> > </head> > <body bgcolor="#000850" text="#FFFFFF" link="FFFF00" > target="main"> > $password2 > <div align="center"> > <font face="Arial, Helvetica, sans-serif" COLOR="#FFFFFF"> > <b>Dear $data[0] $data[1],</b><br><br> > <div align="left">Please enter now the password you have > received by email.<p> > If you did not receive an email within 15 minutes after > applying for a password, <p> > please send an <a href="mailto:XXX\@xxx.xx">email to the > Administrator.</a> > </div> > </font> > <br> > > <form action="login2.cgi" method="post" target="main"> > <input type="hidden" name="action" value="login"> > > <font face="Arial, Helvetica" size="2">Passwort</font> > <input type="password" name="password" size="15"><br><br> > > <input type="Submit" value="Log In"> > </form> > </div> > > $data[0], $data[1] > </body> > </html> > ~; > > } > > } > > ######################################################################### > > sub fetch { > > > my $dbh = DBI->connect( $dsn, $db_user, $db_pass) ; > > ( my $password2 ) = $dbh->selectrow_array( " > select password from memberscopy > where name = '$f_name' > and surname = '$f_surname' " > ); > > return $password2; > > } > > > ######################################################################### > > sub pageone { > > > > > print "Content-type: text/html\n\n"; > > print qq~ > <html> > <head> > <title> Welcome</title> > </head> > <body bgcolor="#000850" text="#FFFFFF" link="FFFF00"> > // $password2 > <div align="center"> > <font face="Verdana, Arial" size="2" color="#FFFFFF"> > <b>ETPA member Area - Welcome ( / $password2)</b></font><br><br> > In this area...[blablablablabla]<br> > <image src="../pics/etp-logo_cr-mini.gif" align="center"> > PASSWORT "$password2" > <hr> > </body> > </html> > ~; > > > > > } > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]