开发者

Browser ask me to download php file

I am a new guy in web programming who still learning new stuff.

I am creating a web form that consist of one INPUT. I connected the form in the HTML file to the php file. I am using a localhost MAMP that I recently installed on my MacBo开发者_开发百科ok.

The Problem : When I open the HTML file on a webpage and type something on the input box and hit submit, the browser ask me to download the php file rather processing it.

I don’t think the problem is related to mysql or apache since when I run the MAMP it give me green signs next to the apache and mysql.

Do anyone know how I can fix this problem and the let the php file open and transfer inputs to the database?


You'll want to make sure that Apache has been told that .php files should be treated as PHP scripts. That means one of the following:

LoadModule php5_module        modules/libphp5.so    # on windows, this'd be a .dll instead
AddHandler php5-script php 

and/or

AddType application/x-httpd-php php

in your httpd.conf file.


open your file from virtual web-server, not filesystem.
you have to type something like

http://localhost/form.html

in your browser's address bar


Did you checked out http://www.mamp.info/en/documentation/faq.html#q8 ?

Maybe you didn't put your site into the folder "htdocs"? PHP won't be parsed unless it is located in that folder or a subfolder.

That would explain the fact that your browser downloads the php file instead of getting the parsed php from apache.


This error is not only about php but general. The file that the browser suggets to down load is simply the script name, php or not.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜