php does not query if the text box is empty
phpIt is very simple to determine whether a variable is empty, just use empty That’s it. The following demonstrates how to make the form content empty without querying.
1. First write the query form
Submit a wd to the server through get
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <form action="a.php" method="get"> <input type="search" name="wd"> <input type="submit" value="查询"> </form> </body> </html>
2. Then make a judgment. The wd is the content of the text box. Use empty for empty judgment
<?php if(!isset($_GET['wd'])) { exit; } if (empty($_GET['wd'])) { die('为空'); } // 在这进行查询处理 echo '正在查询', $_GET['wd'], '...'; ?>
When the content of the text box is empty, the program will execute die and exit, and subsequent query statements will not be executed.
Effect:
##For more PHP related knowledge, please visitPHP Chinese website!
The above is the detailed content of How to implement the query when the php text box is empty. For more information, please follow other related articles on the PHP Chinese website!