valavanp has asked for the wisdom of the Perl Monks concerning the following question:
login.html ---------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE> New Document </TITLE> </HEAD> <BODY> <form id="6" method="post" action="login_1.cgi" name="contact"> <label>Email Address:</label> <div> <input id="element_1" name="element_1" type="text" maxlength="255" val +ue=""/> </div> <label class="description" for="element_2">Web Panel Password:</label> <div> <input id="element_2" name="element_2" class="element text medium" typ +e="password" maxlength="255" value=""/> </div> <input id="saveForm" type="submit" name="Login" value="Login" /> </BODY> </HTML> login_1.cgi ----------- #!c:/perl/bin/perl -w use CGI qw(:standard); use CGI::Carp qw(warningsToBrowser fatalsToBrowser); use DBI; my $dbh=DBI->connect("dbi:mysql:$dbname;",,) || die("cannot connect $! +\n"); $sth = $dbh->prepare("select * from users where email = ?") or &dbdie; $sth->execute($usr) or &dbdie; if (my $name = $sth->fetchrow_hashref) { my $sth = $dbh->prepare("select * from users where password = ?") +or &dbdie; $sth->execute($pwd) or &dbdie; if (my $pass = $sth->fetchrow_hashref){ print "login successful"; print qq(<a href = \"view_user_1.cgi\">user settings</a>); } else { &dienice(qq(The password is invalid.); } }else { &dienice(qq(E-mail does not exist.); } view_user_1.cgi --------------- #!c:/perl/bin/perl -w use CGI qw(:standard); use CGI::Carp qw(warningsToBrowser fatalsToBrowser); use DBI; $q = new CGI; $usr = $q->param('user'); #$usr=$FORM{'inputname'}; #$pwd = $q->param('element_2'); my $dbh=DBI->connect("dbi:mysql:$dbname;",,) || die("cannot connect $! +\n"); $sth = $dbh->prepare("select * from users where email = ? ") or &dbdie +; $sth->execute($usr) or &dbdie; print "Content-type:text/html\n\n"; print "here"; print $usr; my $dbh=DBI->connect("dbi:mysql:$dbname;",,) || die("cannot connect $! +\n"); $sth = $dbh->prepare("select * from users where email = ? ") or &dbdie +; $sth->execute($usr) or &dbdie;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: CGI - variables from first form to be seen in third form.
by FalseVinylShrub (Chaplain) on Nov 24, 2009 at 03:48 UTC |