問題描述
我是網絡編程的新手,仍在學習新東西.
I am a new guy in web programming who still learning new stuff.
我正在創建一個包含一個 INPUT 的 Web 表單.我將 HTML 文件中的表單連接到 php 文件.我正在使用我最近在 MacBook 上安裝的本地主機 MAMP.
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 MacBook.
問題: 當我在網頁上打開 HTML 文件并在輸入框中輸入內容并點擊提交時,瀏覽器要求我下載 php 文件而不是處理它.
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.
我認為問題與 mysql 或 apache 無關,因為當我運行 MAMP 時,它會在 apache 和 mysql 旁邊給我綠色標志.
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.
有誰知道我如何解決這個問題并讓 php 文件打開并將輸入傳輸到數據庫?
Do anyone know how I can fix this problem and the let the php file open and transfer inputs to the database?
推薦答案
您需要確保 Apache 已被告知 .php 文件應被視為 PHP 腳本.這意味著以下之一:
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
和/或
AddType application/x-httpd-php php
在您的 httpd.conf 文件中.
in your httpd.conf file.
這篇關于瀏覽器要求我下載 php 文件的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!