最初のスニペットは、2 つのテキスト フィールドからデータを取得し、 に送信しaction script.php
ます。if
問題は、テキスト フィールドに何も入力しなくても、両方のステートメントが true と評価されることです。何故ですか ?
try.php
<form method='get' action='./action_script.php'>
<input type="text" id="text_first" name="text_first" /> <br />
<input type="text" id="text_second" name="text_second"/> <br />
<input type="submit" id="submit" />
</form>
action_script.php
<?php
if(isset($_GET['text_first'])) {
echo "Data from the first text field : {$_GET['text_first']} <br>";
}
if(isset($_GET['text_second'])) {
echo "Data from the second text field : {$_GET['text_second']} <br>";
}
echo "After the if statement <br />";