Home >Backend Development >PHP Tutorial >Why can I still submit it like this?
This is how to judge. If you only fill in yzm and title without filling in content, why can the submission be successful? Why is this?
If you only fill in yzm and content without filling in the title, the submission cannot be successful. Why does this judgment happen?
<code>if(isset($_POST['yzm'])&&!empty($_POST['title'])&&!empty($_POST['content'])){ echo "提交成功" }</code>
<code><form method="post"> <span name="yzm"></span> <input type="text" name="title"> <textarea name="content"></textarea> <button type="submit"></button> </form></code>
This is how to judge. If you only fill in yzm and title without filling in content, why can the submission be successful? Why is this?
If you only fill in yzm and content without filling in the title, the submission cannot be successful. Why does this judgment happen?
<code>if(isset($_POST['yzm'])&&!empty($_POST['title'])&&!empty($_POST['content'])){ echo "提交成功" }</code>
<code><form method="post"> <span name="yzm"></span> <input type="text" name="title"> <textarea name="content"></textarea> <button type="submit"></button> </form></code>
First of all, your yzm span tag will not be submitted to the $_POST variable. You need to change it to a form element
Then you sort out the business logic, which ones are fillable and which ones are required, and then it will be clearer if you write multiple judgments
I feel like your business logic is not complex enough to require different judgments in different scenarios