【发布时间】:2012-05-12 08:25:52
【问题描述】:
当用户单击按钮时,我想从 php 代码中打印一条消息。我在 php 中添加了代码,并放置了当用户单击按钮时执行的 if 条件。 这是default.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>
应该打印“Ok”。 但我看不到“确定”消息被打印出来。
我能做什么? 谢谢
【问题讨论】:
-
这个代码在
default.php吗? -
如果你用
action="#"替换你的操作是否有效 -
代码在default.php中。如果我用 action="#" 替换操作,我会得到相同的结果。
-
可能你的服务器不知道如何处理 php。看看源代码,看看有没有。
-
我很困惑。当您说查看源代码时,您的意思是像在 Internet Explorer 中运行网站时一样--查看...源代码?如果是,那么是的,我也可以在那里看到 php 代码。
标签: php