How to tell if the user name and password are empty do not execute the following SQL statement

Source: Internet
Author: User
Beginners to consult, the purpose is to determine the form came over the data, if the blank prompt for the user and password, and do not execute down the SQL, if the form inside the data has a value to execute the following SQL statement, here first do not determine whether the form data is legitimate and so on.

$user =$_post[name];  Get the form name$pwd=$_post[passwd];  Get the form passwdif ($user = = ' && $pwd = = ') {    //This place I do not know can be judged, if the user is equal to null, prompt for password   echo ' Please enter user and password ';   } else{                   //If the above two is not empty, execute the following SQL statement and insert it into the database.  $sql = "INSERT INTO (' $user ', ' $pwd ')";  mysql_query ($sql);}


Reply to discussion (solution)

if ($user = = "&& $pwd = =") {//here with | |

if (Empty ($use) | | Empty ($pwd)) {}

if (Empty ($use) | | Empty ($pwd)) {}


I only found out now that if you use | | This means that one is true, and I need to judge two of them to be true.
It's supposed to be && right.
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.