Home  >  Article  >  Backend Development  >  How to implement the query when the php text box is empty

How to implement the query when the php text box is empty

angryTom
angryTomOriginal
2019-11-05 14:36:503019browse

How to implement the query when the php text box is empty

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[&#39;wd&#39;])) {
exit;
}
if (empty($_GET[&#39;wd&#39;])) {
die(&#39;为空&#39;);
}
// 在这进行查询处理
echo &#39;正在查询&#39;, $_GET[&#39;wd&#39;], &#39;...&#39;;
?>

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:

How to implement the query when the php text box is empty

How to implement the query when the php text box is empty

##For more PHP related knowledge, please visit

PHP 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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn