Why the code I wrote on php is not displayed in the browser?

Source: Internet
Author: User
Why is the code I wrote in php not displayed in a browser? & lt ;? Php & nbsp; if (isset ($ _ POST [Submit]) & amp; $ _ POST [Submit] & quot; Login & quot;) {& nbsp; $ user $ _ POST [user]; $ pass $ _ POST [pass]; if (why is this code written on php not displayed in the browser?
If (isset ($ _ POST ['submit ']) & $ _ POST ['submit'] = "login "){
$ User = $ _ POST ['user'];
$ Pass = $ _ POST ['pass'];
If (empty ($ user) | empty ($ pass )){
Echo "script" alert ('user name and password cannot be blank '); script ";
}
Else {
Echo "input username: $ user password: $ pass ";
}
}
?>





The result of running on the browser is blank


------ Solution --------------------
This condition indicates that if (isset ($ _ POST ['submit ']) & $ _ POST ['submit'] = "login") is not true, so it's blank. you can check it in the table. The name of the button is not name = "login ",
If the $ _ POST ['submit '] = "login" condition is not true, change them to the same one,
In addition, the method in form must be submitted using the post method, that is, method = "post"
Yes.
In the form
Write in php as follows:
If (isset ($ _ POST ['login']) & $ _ POST ['login'] = "login "){
$ User = $ _ POST ['user'];
$ Pass = $ _ POST ['pass'];
If (empty ($ user) | empty ($ pass )){
Echo "script" alert ('user name and password cannot be blank '); script ";
}
Else {
Echo "input username: $ user password: $ pass ";
}
}
Else {
Echo "the form has not been submitted ";
}
?>

------ Solution --------------------
Discussion

This condition indicates that if (isset ($ _ POST ['submit ']) & $ _ POST ['submit'] = "login") is not true, so it's blank. you can check it in the table. The name of the button is not name = "login ",
If the $ _ POST ['submit '] = "login" condition is not true, change them to the same one,
In addition, the method in form ......

------ Solution --------------------
Refer to the PHP Manual: language reference-> variables other than PHP
HTML code
  
------ Solution --------------------
$ _ POST ['submit '] = "login"

The value passed in the form (Chinese) is encoded. Of course, the verification fails!
If you change to English

Or you can remove this one, as shown in the following figure. If this key value exists, it is executed.
PHP code
    
------ Solution --------------------
If (isset ($ _ POST ['submit ']) & $ _ POST ['submit'] = "login "){
$ User = $ _ POST ['user'];
$ Pass = $ _ POST ['pass'];
If (empty ($ user) | empty ($ pass )){
Echo "script" alert ('user name and password cannot be blank '); script ";
} // Here is a Braces
} Else {
Echo "input username: $ user password: $ pass ";
}
// This braces are too many}
?>

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.