<分区>
您好,我对以下代码的预期输出有疑问。
我需要打印 You hit T--
消息,同时我看到 Form 2 is here!
消息和按钮。
但现在发生的情况是,当我单击 T--
按钮时,会出现消息,但带有按钮的 Form 2 is here
内容会消失。我需要在打印消息 You hit T--
时在屏幕上显示该消息。
有人可以强调如何纠正这个吗?非常感谢您的关注
代码如下:
<DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<div id="one" style="width:300px; background:gray;">
<form method="post" action="<?= $_SERVER['PHP_SELF'] ?>">
<input type="text" name="txt1" id="txt1">
<?php
if(isset($_POST['sendone']))
{echo "<input type='submit' name='sendtwo' id='sendtwo' value='Two'>";}
?>
<input type="submit" name="sendone" id="sendone" value="One">
</form>
</div>
<div id="two" style="width:300px; background:yellow;">
<?php
if(isset($_POST['sendtwo']))
{echo "Form two is here!"; ?>
<form method="post" action="<?= $_SERVER['PHP_SELF'] ?>">
<?php echo "<input type='submit' name='sendt' id='sendt' value='T--'>";}
if(isset($_POST['sendt'])) {echo "You hit T--"; return;}
?>
</form>
</div>
</body>
</html>