Strange $_POST behaviour?!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mashruf
Forum Newbie
Posts: 2
Joined: Sun May 23, 2010 5:27 pm

Strange $_POST behaviour?!

Post by mashruf »

I have saved following code by login.php name and put that file on a server. But the problem is whenever I run the file it shows ''success!" allways. Why so? I can't understand.. Please help...

Code: Select all

<?php
      $con = mysql_connect("localhost","s_admin","habijabi");

      mysql_select_db("aluvhaji",$con);

        //Receive form data
        $uname = $_POST["titl"];
        $pword = $_POST["desc"];

	$value = mysql_query("select * from user where username = '$uname' and password='$pword'",$con);
		
        if($value)
        {
               echo "success!";
        }
        else die('Error: ' . mysql_error());
?>
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Strange $_POST behaviour?!

Post by requinix »

mysql_query returns a resource for a SELECT query, not a boolean* or an array.

If you want to look at the number of rows use mysql_num_rows.


* Unless the query fails, for which you'll get false back.
mashruf
Forum Newbie
Posts: 2
Joined: Sun May 23, 2010 5:27 pm

Re: Strange $_POST behaviour?!

Post by mashruf »

Thanks for the clarification. It speaks a lot...
Post Reply