[PHP-DB] String comparision issue with change of databases

2007-11-23 Thread Tamkhane, Pravin

Hi All,
I am trying to write a simple user verification(not using MD5 hash) . I have 
users table in database which contains login_id and passwd for registered 
users. I am using PDO for this purpose. If i use MySQL database, following 
code for user verification works well without any problem. But if change 
$dsn to use PostgreSQL database, code fails at  if( $passwd === 
$records[0]['passwd']). After some experiementation, I realized that $passwd 
holds password string ( assume '1234' for time being) In case of MySQL 
$records[0]['passwd'] holds password string '1234' as expected and code 
works. But in case of PostgreSQL,  $records[0]['passwd'] holds 1234 rather 
than '1234' and hence comparison fails. Since I am using same code to 
register users in both cases, I doubt there would be any issue there.


{
$loginId = $_REQUEST['loginid'];
$passwd = $_REQUEST['passwd'];

$dsn = mysql:host=$hostName;dbname=$dbName;
$query = SELECT * FROM users WHERE login_id='$loginId';;

$dbh = new PDO($dsn, $userName, $passWd);

$result = $dbh-query($query);
$records = $result-fetchAll(PDO::FETCH_ASSOC);

if(!count($records))
{
 echo 'br/User does not exist! A href=registeruser.htmlGet Resgitered 
Now!!/A';

}
else
{
 if( $passwd === $records[0]['passwd'])
 {
  echo 'br/Userb '.$loginId.'/b logged in successfully!';
 }
 else
 {
  echo 'br/Invalid Password! A href=index.htmlTry Again/A';
 }
}
$dbh = null;
}

Any pointers please? Any hints?

Thanks,
Pravin

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] category management using MySQL and PHP

2006-11-07 Thread Tamkhane, Pravin
Hi All,
I am working on small web project based on PHP  MySQL where user is looking 
for items in certain categories and he specifies the category in search box, 
the search result should return all items from that category  sub-categories 
of it. 

I thought of defining a unique identifier to each category and use them in 
search but it may work well only for base categories, for hierarchical/sub  
categories I doubt it will make it simple. Any hints on how can I solve this? 
Any pointers would be greatly helpful.

Thanks in advance,
Pravin

[PHP-DB] Page refresh and database updation

2006-09-26 Thread Tamkhane, Pravin

Hi All,
I am a PHP newbie. I am using HTTP POST request to send some data to Apache and then using MySql to store that information. Once 
information is stored in MySql DB successfully, I display a result page. But the problem I am facing is that, if I refresh the 
result page displayed after database updation, the information is stored again in database which I don't want to. Please guide me on 
how I can avoid duplication of information in database on refreshing the page. Thanks in advance!


Regards,
Pravin 


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php