dou760663 2015-06-17 09:33 采纳率: 100%
浏览 80
已采纳

从HTML文件WAMP运行php脚本

So I have been following this tutorial here

I have installed WAMP and the server is up and running just fine. (As the green light in the taskbar indicates).

In the www folder I have the following 2 files:

        <!DOCTYPE html>
        <html>
        <head>
        <title>First Form</title>
        </head>
        <body>

             <form action="postForm.php" method="post">

             <TextArea 

                name="microBlog" id="microBlog" cols="30" rows=“10">

             </TextArea>  

             <input type="submit">          

            </form>

        </body>
        </html>

and

    <!DOCTYPE html>
    <html>
     <head>
      <title>PHP Test</title>
     </head>
     <body>

        <?php 

            $microBlog = $_POST['microBlog'];          
            echo $microBlog;  

        ?> 

     </body>
    </html> 

However, when I run the html file and input "hello" into the field, clicking the submit button returns a blank screen.

Here is the html screen on open:

enter image description here

and on clicking submit the following is in the address bar:

file:///C:/wamp/www/postForm.php

Any ideas why the blank screen?

Does the PHP (postForm) file require HTML tags or can I get rid of them?

  • 写回答

2条回答 默认 最新

  • dongqing220586 2015-06-17 09:43
    关注

    Open the file via http://localhost/... The reason for the blank screen is: You can open a html-file with the explorer and it will work fine because it will be rendered by the default-web-browser. you need a parser for php-scripts. The Webserver will use this parser if you add the extension .php but if you open the file in the Explorer you don't use the Webserver (in your case apache). If you want to open the file in the explorer set the action-attribute to action="http://localhost/postForm.php" and it will work.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 C语言PE文件遍历节表
  • ¥15 求C# .net4.8小报表工具
  • ¥15 安装虚拟机时出现问题
  • ¥15 Selenium+docker Chrome不能运行
  • ¥15 mac电脑,安装charles后无法正常抓包
  • ¥18 visio打开文件一直显示文件未找到
  • ¥15 请教一下,openwrt如何让同一usb储存设备拔插后设备符号不变?
  • ¥50 使用quartz框架进行分布式任务定时调度,启动了两个实例,但是只有一个实例参与调度,另外一个实例没有参与调度,不知道是为什么?请各位帮助看一下原因!!
  • ¥50 怎么获取Ace Editor中的python代码后怎么调用Skulpt执行代码
  • ¥30 fpga基于dds生成幅值相位频率和波形可调的容易信号发生器。