Home >Backend Development >PHP Tutorial >Why can I still submit it like this?

Why can I still submit it like this?

WBOY
WBOYOriginal
2016-07-06 13:53:001058browse

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>

Reply content:

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

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