我想打印来自php代码的消息,当用户点击按钮。我添加了代码在PHP中,并放置,如果条件执行时,用户点击按钮。 这里是如default.php的代码:PHP打印消息
<?php
if (isset($_POST['button1'])) {
echo '<b>Ok.</b>';
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>PHP3</title>
</head>
<body>
<p> </p>
<p> </p>
<p> </p>
<form id="form1" name="form1" method="post" action="default.php">
<p>
<label for="textfield1">User Name</label>
<input type="text" name="username" id="username" />
</p>
<p>
<label for="textfield2">Password</label>
<input type="password" name="password" id="password" />
</p>
<p>
<input type="submit" name="button1" id="button1" value="Submit" />
<br />
<br />
<label id="label1">
</label></p>
<p> </p>
</form>
<p> </p>
</body>
</html>
“确定” 应打印。 但我看不到“好”的消息打印。
我该怎么办? 谢谢
这是'default.php'中的代码吗? –
如果你用'action =“#”替换你的动作,它会工作吗? –
代码在default.php中。如果我用动作=“#”替换动作,我有相同的结果。 – pyram