Tengo el problema con un login que hice usando perl CGI ... resulta que aunque ponga un registro que ya hiciste en la base de datos me devuelve el alert de datos incorrectos.
El código es el siguiente:
#!"C:\xampp\perl\bin\perl.exe"
use Digest::MD5 qw(md5 md5_hex md5_base64);
use CGI;
use DBI;
use strict;
use CGI::Session;
use CGI::Carp qw(fatalsToBrowser);
my $cgi = new CGI;
my $email = $cgi->param('email',$cgi->param("email"));
my $pass = $cgi->param('pass',$cgi->param("pass"));
my $pwd = md5($pass);
my $root="root";
my $pass="";
my $host="localhost";
my $db="amaclone";
my $sql=DBI->connect("DBI:mysql:$db;host=$host",$root,$pass);
my $consulta = "SELECT * FROM user_info WHERE email='$email' And password='pwd'";
my $consulta2 = $sql->prepare($consulta);
my $row = $consulta2->fetchrow_hashref();
my $encontrar = 0;
while ($consulta2->fetch())
{
$encontrar = 1;
}
if($encontrar eq 1)
{
my $session=new CGI::Session;
$session->param('uid', $row->{user_id});
$session->param('uname', $row->{first_name});
$session->expire("+1h");
$session->flush();
print $session->header(-location => "privado.cgi");
}else{
print $cgi->header(-type=> 'text/html',
-charset=>'utf-8');
print "<script>alert('Datos incorrectos')</script>";
print "
<script>
exit;
</script>"
}
$sql->disconnect();