Login | Register | FAQ
Anonymous

Resource id #9

+ Post a reply

2 posts Page 1 of 1


Resource id #9

by blacblu » Fri Jun 29, 2012 12:28 am

Hi.

I'm trying to get an specific data from my database using this line of code:

[php]$strusername = mysql_query('SELECT Username FROM Users WHERE Password = "$_POST[password]" '); [/php]

But it is returning the following: Resource id #9

Here goes the entire code:

Code: Select all
   <html>
   <head>
   <title>Home2</title>
   </head>

   <body style="background-image:url(novofundo.jpg)">
   <?php
      mysql_connect("mysql5.000webhost.com", "a9698509_blacblu", "nopassword1");
      mysql_select_db("a9698509_blacblu") or die(mysql_error());   
      $strusername = mysql_query('SELECT Username FROM Users WHERE Password = "$_POST[password]" '); 
      //$strpassword = mysql_query('SELECT Password FROM Users WHERE Username = "$_POST[username]" '); 
      if(strlen($_POST[password]) > 0 && strlen($_POST[username]) > 0){
         if($strusername == $_POST[username] && $strpassword == $_POST[password]){
            session_start();
            $_SESSION["Login"] = "YES";
            echo "<h1>Ol? " .$_POST["username"]. "</h1>";
            echo "<h2>seu grafico esta aqui</h2>";//colocar grafico aqui         
         }
         else{
            session_start();
            $_SESSION["Login"] = "NO";
            echo "<h1>Seus dados estao incorretos.</h1>";            
         }
      }else{
         session_start();
           $_SESSION["Login"] = "NO";
           echo "<h1>Voc? deixou um ou mais campos em branco.</h1>";      
      }
      echo $strusername;
      echo $strpassword;      
      
   
      
   ?>
   </body>
   </html>


What is being done wrong?

Thank you.
User avatar

blacblu

  • Posts: 5
  • Joined: Fri Jun 29, 2012 12:26 am

Re: Resource id #9

by XainPro » Fri Jun 29, 2012 11:19 am

<?php
session_start();
?>

<html>
<head>
<title>Home2</title>
</head>

<body style="background-image:url(novofundo.jpg)">
<?php
mysql_connect("mysql5.000webhost.com", "a9698509_blacblu", "nopassword1");
mysql_select_db("a9698509_blacblu") or die(mysql_error());
if(strlen($_POST[password]) > 0 && strlen($_POST[username]) > 0){


$data = mysql_query('SELECT Username FROM Users WHERE Username = "$_POST[username]" AND Password = "$_POST[password]" ');
if(mysql_num_rows($data) == 1){

$Info = mysql_fetch_array($data);

$_SESSION["Login"] = "YES";
echo "<h1>Ol? " .$Info["Username"]. "</h1>";
echo "<h2>seu grafico esta aqui</h2>";//colocar grafico aqui
}
else{

$_SESSION["Login"] = "NO";
echo "<h1>Seus dados estao incorretos.</h1>";
}
}else{
$_SESSION["Login"] = "NO";
echo "<h1>Voc? deixou um ou mais campos em branco.</h1>";
}
echo $Info["Username"];
echo $Info["Password"];



?>
</body>
</html>



need to edit like this :)
User avatar

XainPro

  • Posts: 3661
  • Joined: Fri Feb 17, 2012 8:10 pm


+ Post a reply

Page 1 of 1