Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Comment on

by gods
on Feb 11, 2000 at 00:06 UTC ( #3333=superdoc: print w/replies, xml ) Need Help??
Hi All,
I have a login form when it is submitted it will be directed to the login_1.cgi to check it with the database, after it is successful there is a view_user hyper link which directs it to the user information page. I wanted to have the user name from login page available to the user information page to get the values from the db. But i am not able to populate the user values available to the user information page. Because the user information page is the 3rd page which i am not able to populate the values from the first page. Could anyone suggest me a method. I also tried to have an hidden variable. But there is no form submission in the 2nd page. Here is the code drop for your reference and thanks for the time.
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;

In reply to CGI - variables from first form to be seen in third form. by valavanp

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others taking refuge in the Monastery: (15)
    As of 2016-09-30 15:43 GMT
    Find Nodes?
      Voting Booth?
      Extraterrestrials haven't visited the Earth yet because:

      Results (570 votes). Check out past polls.