Jump to content

Hi, I need help with this:


ted_chou12

Recommended Posts

[code]
<?php
require("../mysqlconnection.php");
$sql = "SELECT username FROM userinfo WHERE username = '$username'";
$result = mysql_query($sql);
if (mysql_num_rows($result) > 0)
{
$row = mysql_fetch_array($result);
$pass = $row['password'];
if($md5pass == $pass)
return true;
else
return false;}
?>
can anyone have a look at this? because it doesnt get both the uesrname and password at all....
THanks
Ted[/code]
Link to comment
https://forums.phpfreaks.com/topic/31778-hi-i-need-help-with-this/
Share on other sites

You're only asking for the username from the DB. If you want to retrieve the password you have to ask the DB for it.
[code]<?php
require("../mysqlconnection.php");
$sql = "SELECT username, password FROM userinfo WHERE username = '$username'";
$result = mysql_query($sql);
if (mysql_num_rows($result) > 0)
{
        $row = mysql_fetch_assoc($result);
      $pass = $row['password'];
      if($md5pass == $pass)
  return true;
      else
  return false;}
?>[/code]

Ken

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.