dongpenggan6812 2019-03-18 16:41
浏览 26

如何才能使这个简单的表格正常运行?

I'm trying to get this script in php to work but it doesn't want to:

<body>
<FORM ACTION="second.php" METHOD="post">
YourName:
<INPUT TYPE="text" NAME="YourName"><BR />
CostOfLunch:
<INPUT TYPE="text" NAME="CostOfLunch"><BR />
DaysBuyingLunch:
<INPUT TYPE="text" NAME="DaysBuyingLunch"><BR />
<INPUT TYPE="submit" NAME="x" VALUE="Calculate">
</FORM>
</body>

And the second file.

<body>
<?php $Today = date("l F d. Y"); ?>
   Today's Date: 
   <?php 
   /* 
   ** show today's date
   */
   print("<H3>$Today</H3>");     
   /*
   ** show information about cost of lunch
   */
   print("$YourName, this week, you will spend ");
   print($CostOfLunch * $DaysBuyingLunch);
   print(" dollars for lunch.<BR />
");
?>
</body>

I'm testing these files in two ways:

  1. By running php -S 0.0.0.0:8000 first.php this command in cmd. And then navigating to adress bar in browser. I'm typing there http://localhost:8000/. In this way the page doesn't output the second.php but shows first page and clears the forms. It changes to http://localhost:8000/second.php though.
  2. By typing http://localhost:portnumber/first.php in the adress bar. This works somewhat better cause I have installed the Appache HTTP Server. It navigates to http://localhost:port/second.php and changes the output of the site to the content of a file. Alas like this: Today's Date: , this week, you will spend 0 dollars for lunch. without running any script.

EDIT: Changing script to use echo and $_POST instead of print() like this <?php echo $_POST['yourName']; ?> have worked. But only when using APACHE. When using built-in web server site content is not changing just clearing.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
    • ¥500 火焰左右视图、视差(基于双目相机)
    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?