David Silva wrote:
> Hi everyone,
> 
> I have a form with username and password, and when the user enter the right
> user and pass he/she go to other page. (that is my thought)
> 
> What i did?
> 
>     my $dbcon= DBI->connect("dbi:mysql:dbname=dbcontactos","root","");
>     my $sql = $dbcon->prepare("select name,pass from Utilizador where
> name='?' and pass='?'");

I don't think you want those ' single quotes around the parameter
markers (?) and you'd be better using single quotes here or q{}.

>         $sql->execute($user,$pass);


When will $sql be 1 here? You want to fetch the row you selected and if
no row comes back the username/password combination does not exist else
it is a correct login.

>     if($sql == 1){
> redirect to other page
>     }
>     if($sql == 0){
> stay in the login page
>     }
> 
> My problem is that i can't see any other way to do this and even if the
> values are correct with the ones in database it stays in the login page.

Because $sql is never 1, it is a DBI statement handle - see above.

> How can i do this?
> 
> Thank you

You might want to thing about setting RaiseError or checking things like
execute/prepare etc complete successfully too.

Martin
-- 
Martin J. Evans
Easysoft Limited
http://www.easysoft.com

Reply via email to