php mysql related question?

ApurvA

New member
JAI MATADI all . .

i m working in php with mysql database ..

i have one simple signup form .. in which the user will have to enter his/her new username and password and etc . .here is my form .. (i havent mentioned the full here)

-----------------------------------------------------------------
try.php
-----------------------------------------------------------------
<form method="post" name="f1" id="f1" >
UserName : <input type="text" name="uname" id="uname" />
<br />
Password : <input type="text" name="password" id="password" />
<br />
<input type="submit" id="submit" name="submit" />
</form>
<?php

if(isset($_POST["submit"]))
{
$usname = $_POST["uname"];
$psword = $_POST["password"];
mysql_connect("localhost","root","");
mysql_select_db("alldatabase");

$qry = mysql_num_rows(mysql_query("select * from signup where username='$usname' and psword='$psword'"));
if($qry == 1)
{
echo "Username Already Exists";
}
else
{
echo "Success";
}
}
?>

----------------------------------------------------------------

one problem m facing here .. m not able to fetch the Two values to get the result either the username already exits or not ..

when i m trying to find only username with this code .. its working well .. but when i m trying to find more then one value m getting this result ..

---------------------------------------------------------
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\wamp\www\login and etc database\try.php on line 27
---------------------------------------------------------

please tell me how can i fetch that ..

thank you ..
i've also tried this ..

<?php

if(isset($_POST["submit"]))
{
$usname = $_POST["uname"];
$psword = $_POST["password"];
mysql_connect("localhost","root","");
mysql_select_db("alldatabase");
$qry = "select * from signup where username='$usname' and pword='$psword'";
/*$qry = mysql_num_rows(mysql_query("select * from signup where username='$usname'"));*/
if(mysql_query($qry))
{
echo "Username Already Exists";
}
else
{
echo "Success";
}
}
?>

but nothing working as i m getting the same result saying "The Username Alread Exists" Evenif its not in my database at all .. :( help me ..
 
Back
Top