How to use if in php to determine whether the text box is equal to empty

藏色散人
Release: 2023-03-02 13:26:02
Original
3929 people have browsed it

php If is not equal to empty judgment method: first obtain the content of the text box through "$_POST['content'];"; then use "if($content==""){}else{} "method to determine whether the text box content is empty; finally execute the relevant file in the browser.

How to use if in php to determine whether the text box is equal to empty

To determine whether the value of a form element is empty in PHP, you first need to submit the form, and then get the form element based on its name to determine whether it is empty.

Examples are as follows:

<?php
if($_POST[&#39;sub&#39;]){
//获取文本框的内容
$content=$_POST[&#39;content&#39;];
if($content==""){
echo "文本框内容为空!";
}else{
echo "文本框内容不为空!";
}
 
}
 
 
?>
<html>
<head>
<title>演示</title>
</head>
<body>
<form name="form1" action="<?php echo $_SERVER[&#39;PHP_SELF&#39;]; ?>" method="post">
<input type="input" name="content"/>
<input type="submit" name="sub"  value="提交"/>
</form>
 
</body>
</html>
Copy after login

For more related knowledge, please visit PHP Chinese website!

The above is the detailed content of How to use if in php to determine whether the text box is equal to empty. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template