Why can I still submit it like this?

WBOY
Release: 2016-07-06 13:53:00
Original
1038 people have browsed it

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>
Copy after login
Copy after login
<code><form method="post">
    <span name="yzm"></span>
    <input type="text" name="title">
    <textarea name="content"></textarea>
    <button type="submit"></button>
</form></code>
Copy after login
Copy after login

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>
Copy after login
Copy after login
<code><form method="post">
    <span name="yzm"></span>
    <input type="text" name="title">
    <textarea name="content"></textarea>
    <button type="submit"></button>
</form></code>
Copy after login
Copy after login

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

Related labels:
php
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!