Cristal Wrote:
-------------------------------------------------------
> Thank you for the answers.
>
> I removed the extra whitespaces and I have the
> same problem.
> Yes I created a db account.
>
> I verified that in my table the field
> user_password has something like
> *D37C40049.........., and not youcango.
>
> So, I added the lines:
>
> $password= md5("youcango"
> echo "$password";
>
> and I have another number like 00F7C1...........
> that is different from the number that I have in
> my database field user_password, I think the
> problem is the encription type that is in my sql
> table.
>
> Thank you,
Seems you have setup your password field incorrectly. For MD5 encryption you should set your field up as VARCHAR(32)
To fix this open phpmyadmin select your database then find your tbl_auth_user table. Click the operations tab and select the EMTPY tab. This will clear you table.
Next select the structure tab. Find the password field and click then pencil icon next to it. Now find the TYPE field and select VARCHAR and enter 32 for the LENGTH. Click Go.
Now click the INSERT tab to insert a new record. When you get to the password field select MD5 from the FUNCTIONS column and now enter your password. Click Go when finished.
Now in your script use this:
<?php
session_start();
include 'config.php';
include 'opendb.php';
$errorMessage = '';
if (isset($_POST['txtUserId']) && isset($_POST['txtPassword']))
{
$userId = mysql_real_escape_string($_POST['txtUserId']);
// encrypt the password before using it in the query
$password = md5($_POST['txtPassword']);
$sql= "SELECT * FROM tbl_auth_user WHERE user_id = '$userId' AND user_password = '$password'";
$res = mysql_query($sql) or die (mysql_error());
echo mysql_num_rows($res);
}
include 'closedb.php';
?>