PHP表单提交,结果显示的是处理表单页面的文件名?
这个是表单所在页面
<html>
<head>
<title> figure 1.4 </title>
</head>
<body>
<form action = "15.php " method= "post ">
Your Name:
<input type = "text " name= "YourName "> <BR>
Cost of a Lunch:
<input type= "text " name= "CostOfLunch "> <br>
Days Buying Lunch:
<input type= "text " name= "DaysBuyingLunch "> <br>
<input type= "submit ">
</form>
</body>
这个是处理页面,只定义了
</html>
<?
$Today = date( "l F d,Y ");
?>
<html>
<body>
Today 's Date:
<?
print( " <h3> $Today </h3> ");
print ( "$YourName,your will be out ");
print ($CostOfLunch*$DaysBuyingLunch);
print ( " dollars this wek. <br> \n ");
?>
</body>
</html>
但是我点击提交后,并没有解析文件内容,而是显示 “blank15.php”,15.php是我处理表单的文件名。
为什么会这样?
------解决方案--------------------没有 接收参数
</html>
<?php
$Today = date( "l F d,Y ");
$YourName = $_POST[ 'YourName '];
$CostOfLunch = $_POST[ 'CostOfLunch '];
$DaysBuyingLunch = $_POST[ '$DaysBuyingLunch '];
?>
<html>
<body>
Today 's Date:
<?php
print( " <h3> $Today </h3> ");
print ( "$YourName,your will be out ");
print ($CostOfLunch*$DaysBuyingLunch);
print ( " dollars this wek. <br> \n ");
?>
</body>
</html>
------解决方案--------------------1.你那人是显示那个呢.还是浏览器中显示是那个.
2.如果提交了以后可能会出现变量过不过的情况.你就得用$_POST[ '你提交的变量名不加$ ']来接收。
3。这个很简单。如果你提交对了。没问题的。
------解决方案--------------------教材代码应该没问题!可能还是运行环境那设置的事!
现在一般都用$_POST[ 'YourName ']获取表单POST过来的数据