Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Comment on

( #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
    [ambrus]: Corion: from the docs, it definitely looks like it would be possible to write an AnyEvent driver for it using Prima::File and Prima::Timer.
    [ambrus]: (I haven't found an idle event.)
    [ambrus]: However, I also looked at the internals, and found two interesting things:
    [marto]: stupid xpath question, I have a xpath copied from the browser, is the * wildcard supposed to work for IDs? e.g. '//*[@id="*"]/ div/div/header/p/a '?
    [ambrus]: The main loop for unixish systems is in https://metacpan. org/source/ KARASIK/Prima-1. 49/unix/apc_app.c. It is a hand-rolled select loop, but also always spins at least once every 0.2 seconds for some reason.
    [ambrus]: marto: no, not that way. if you just want to test for an existing id attribute, then write *[@id] , or you can match a regexp to the value of that attribute like *[@id=~/something/ ]
    [marto]: ambrus, thanks I ended up going with '//*[starts- with(@id, "thread_")]...
    [ambrus]: Sometimes it's easier to just match elements in ways other than xpath, like directly with perl code.

    How do I use this? | Other CB clients
    Other Users?
    Others about the Monastery: (6)
    As of 2016-12-08 10:50 GMT
    Find Nodes?
      Voting Booth?
      On a regular basis, I'm most likely to spy upon:

      Results (140 votes). Check out past polls.