in reply to Re^7: cookie problem
in thread cookie problem

Where is the username and password entered ?

Replies are listed 'Best First'.
Re^9: cookie problem
by bigup401 (Pilgrim) on Nov 13, 2014 at 10:43 UTC

    in html source

    <input type="text" name="username"/> <input type="password" name="password"/>

    and i did as u side

    my $cgi = CGI->new(); my $sid = $cgi->cookie('login'); if ( ! $sid ){ print $cgi->redirect(-uri=>"home.pl", -cookie=>$cookie); } else { print $cgi->header(-cookie=>$cookie); }
      'in html source'
      Is this html code generated by another script ?

        here is full scrip with html source

        #!"C:\xampp\perl\bin\perl.exe" use DBI; use CGI; $cgi = CGI->new(); $db ="datab"; $usr ="root"; $pwd =""; $host ="localhost"; $dbh = DBI->connect("DBI:mysql:$db:$host", $usr, $pwd { AutoCommit => 0, RaiseError => 1, } ) or die $DBI::errstr; my $username = $cgi->param('username'); my $password = $cgi->param('password'); my $sth = $dbh->prepare("select id from mysql_auth where username = ? +AND password=?"); $sth->execute($username, $password); if ($x = $sth->fetchrow()) { $sth->finish(); $cookie = $cgi->cookie(-name=>'id', -value=>$username); print $cgi->redirect(-location=>"welcome.pl", -cookie=>$cookie); } else { print $cgi->redirect("wrong_username or password.pl"); } print "Content-type: text/html\n\n"; print <<START_HTML; <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:/ +/www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <p>username <input type="text" name="username" /> </p> <p>password <input type="password" name="password" /> </p> <p> <input type="submit" name="button" value="Submit" /> </p> </body> </html> START_HTML