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

Source: Internet
Author: User
How to tell if the user name and password are empty do not execute the following SQL statement
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 name of the form
$pwd =$_POST[PASSWD]; Get the form's passwd

if ($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);
}

Share to:


------Solution--------------------
if ($user = = "&& $pwd = =") {//used here
------Solution--------------------
better.
------Solution--------------------

if (Empty ($use)
------Solution--------------------
Empty ($pwd)) {
}
  • 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.