嗨,我在下面放了一个示例代码来解释我的担忧。除了在页面上的所需位置显示“回声”消息外,代码工作正常。执行代码时,回显消息仅出现在页面上,但我需要该消息出现在“cell4”表格单元格中。
我尝试将代码修改为 {echo "Name is blank!"; return false;} 在第 30 行,但似乎它不是正确的方法,因为结果没有变化。有人可以告诉我有没有解决方法?感谢您的关注。
代码如下:
<html>
<head><title>Test</title></head>
<body>
<form method="POST" action="<?= $_SERVER['PHP_SELF'] ?>">
<table border="1">
<thead>
<tr>
<td colspan="4">User detail</td>
</tr>
</thead>
<tr>
<td id="cell1">Name:</td>
<td id="cell2"><input type="text" name="Uname"></td>
<td id="cell3"><input type="submit" name="SendNow" value="Save"></td>
<td id="cell4"></td>
</tr>
</table>
</form>
</body>
</html>
<?php
if(isset($_POST['SendNow']))
{
$nm = $_POST['Uname'];
if($nm == "")
{echo "Name is blank!"; return false;}
else
{echo "Well done!"; return false;}
}
?>
Sorry the edited code has not appeared correct in the above text. This is how I have tried modifying : {echo "<td id='cell4'>Name is blank!</td>"; return false;}