我想打印來自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