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 防火墙的混合模式配置
  • ¥15 Ubuntu不小心注销了要怎么恢复啊
  • ¥15 安装powerbuilder10卡在安装程序正在运行这个页面 没有下一步任何指令
  • ¥15 关于mpi的问题:请问遇到这种情况需要怎么解决,出现这个问题后电脑不能进行mpi多核运行只能进行单核运行
  • ¥50 微信聊天记录备份到电脑提示成功了,但还是没同步到电脑微信
  • ¥15 python怎么在已有视频文件后添加新帧
  • ¥20 虚幻UE引擎如何让多个同一个蓝图的NPC执行一样的动画,
  • ¥15 fluent里模拟降膜反应的UDF编写
  • ¥15 MYSQL 多表拼接link
  • ¥15 关于某款2.13寸墨水屏的问题