我正在运行一个非常简单的 HTML 页面,其中包含表单。我通过 POST 方法发送数据并在 PHP 页面上处理它们。我做了一个简单的 if 语句来检查是否所有输入都已填写。如果不是,则返回为假。
问题是,当某些输入未填写时,这些字段就像在 PHP 页面上填写一样,并且 if 语句返回 TRUE 并且 PAGE 继续处理。我做错了什么?
HTML:
<form class="add_content grid_12 alpha" enctype="multipart/form-data"
method="POST" action="add_content_2.php" name="excersise_upload">
<ul>
<li>
<label for="excersise_name">Název cviku:</label><br />
<input type="text" name="excersise_name" id="excersise_name">
</li>
<li>
<label for="selected_part">Partie cviku:</label><br />
<select name="selected_part" id="selected_part">
<?php
get_parts();
?>
</select>
</li>
<li>
<label for="selected_difficulty">Vyber obtížnost cviku:</label>
<br />
<select name="selected_difficulty" id="selected_difficulty">
<option value="1">začátečník</option>
<option value="2">mírně pokročilý</option>
<option value="3">pokročilý</option>
</select>
</li>
<li>
<label for="excersise_info">Popis cviku:</label><br />
<textarea name="excersise_info" id="excersise_info"></textarea>
</li>
<li>
<input name="MAX_FILE_SIZE" value="102400" type="hidden">
<input type="file" name="excersise_image" accept="image/jpeg">
</li>
<li>
<label for="image_name">Název obrázku:</label><br />
<input type="text" name="image_name" id="image_name">
</li>
<li>
<input type="submit" value="Přidat do databáze">
</li>
</ul>
</form>
PHP:
if ((isset($_POST['excersise_name'])) &&
(isset($_POST['selected_part'])) &&
(isset($_POST['selected_difficulty'])) &&
(isset($_POST['excersise_info'])) &&
(isset($_FILES['excersise_image'])) &&
//(isset($_FILES['image_name'])) &&
$_FILES['excersise_image']['size'] > 0) {.....