if($username&&$password)
{
$connect = mysql_connect("localhost","root","") or ("Couldn't connect!");
mysql_select_db("phplogin") or die ("Couldn't find db");
$query = mysql_query("Select * FROM users WHERE username='$username'");
$numrow= mysql_num_rows($query);




i just wont to know the IF statement when it stars what is his function in the code.

Recommended Answers

All 6 Replies

Member Avatar for diafol

The is no user-defined function in your code. To which function are you referring?
Are the $username and $password variables set? If not, you may get an error with the straight boolean test. Test for the existence before testing for content:

if(isset($username) && isset($password) && $username && $password){
    ...
}

OR use empty() - note !empty() is the positive test

if(!empty($username) && !empty($password)){
...
}

:) i just wont to know how the IF works the if($username&&$password) they are createt in another page this is a login logout,im traying to understand that code.can you explain what this mean if($username&&$password).

hey is somebody there im waiting for help

commented: Oh, well everyone should just stop their lives and answer you. -3

It tests if both variables are not empty.

commented: thnx pritaeas +2
Member Avatar for diafol

hey is somebody there im waiting for help

I thought I answered your question. :(
Pritaeas has clarified, I hope that's enough for you.
Please mark as solved if it is.

commented: thnx very helpful your info ; ) +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.