File Download Dialog when opening PHP files

Problems with the Windows version of XAMPP, questions, comments, and anything related.

File Download Dialog when opening PHP files

Postby drh3010 » 12. December 2009 07:04

When I try to open a PHP file I get the File Download dialog. I installed XAMPP a month ago and everything worked fine. Recently I was hospitalized for a week and now I have the problem. In other words, I haven't touched my computer.

Everything I've read says PHP isn't enabled. However, I can see XAMPP's page when I go to http://localhost/ and the phpinfo() link works when I click it.

Any ideas?
drh3010
 
Posts: 4
Joined: 12. December 2009 06:55

Re: File Download Dialog when opening PHP files

Postby Izzy » 12. December 2009 07:16

Missing support info - what XAMPP version and which Windows OS?
drh3010 wrote:When I try to open a PHP file I get the File Download dialog.
What exactly are you typing in the browser's address bar to "open a PHP file" that is giving you this issues?

What is the very first line, the top most line of your php page?


Some helpful reading for new XAMPP users:
\xampp\readme_en.txt file
or
http://www.apachefriends.org/winxampp/readme_en.txt

http://www.apachefriends.org/en/xampp-windows.html
http://www.apachefriends.org/en/faq-xampp-windows.html
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Re: File Download Dialog when opening PHP files

Postby drh3010 » 12. December 2009 07:28

XAMPP for Windows Version 1.7.2
XAMPP Control Panel Version 2.5.8 (2009-07-28)
Windows 5.1 Build 2600 Platform 2 Service Pack 3 (XP)

Below is the orderform.html file I run which displays fine. Then I click the "submit" button and instead of seeing the processorder.php page, I get the File Open dialog asking me if I want to open or save the PHP file. This is the first exercise in the book PHP and MySQL Web Development, Addison/Wesley press.

orderform.html
================================================
<html>
<body>
<form action="processorder.php" method="post">
<table border="0">
<tr bgcolor="#cccccc">
<td width="150">Item</td>
<td width="15">Quantity</td>
</tr>
<tr>
<td>Tires</td>
<td align="center"><input type="text" name="tireqty" size="3" maxlength="3" /></td>
</tr>
<tr>
<td>Oil</td>
<td align="center"><input type="text" name="oilqty" size="3" maxlength="3" /></td>
</tr>
<tr>
<td>Spark Plugs</td>
<td align="center"><input type="text" name="sparkqty" size="3" maxlength="3" /></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="Submit Order" /></td>
</tr>
</body>
</html>

processorder.php
======================================================================
<html>
<head>
<title>Bob's Auto Parts - Order Results</title>
</head>
<body>
<h1>Bob's Auto Parts</h1>
<h2>Order Results</h2>
<?php
echo '<p>Order Processed.</p>';
?>
</body>
</html>
drh3010
 
Posts: 4
Joined: 12. December 2009 06:55

Re: File Download Dialog when opening PHP files

Postby Izzy » 12. December 2009 07:38

I have just created your 2 pages and put them in the htdocs folder, tested and they work fine.

http://localhost/orderform.html gives me three boxes I can add quantities, which I did by adding 1 in each box, then pressed Submit Order.

The processor.php returned:
"Bob's Auto Parts
Order Results
Order Processed."

So on a default XAMPP 1.7.2 installation both your files seem to work just fine.

Try and clear your browser's cache and give it another go.

Also make sure that Apache and MySQL are both showing a green running in the XAMPP Control Panel.

BTW there is no form closing tag in your markup </form> which should go on the line before </body> tag.

Another little tip, when you have issues with the web server the first place to check is the \xampp\apache\logs\error.log file as it quite often contains good clues that may help with troubleshooting the issues.
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Re: File Download Dialog when opening PHP files

Postby drh3010 » 12. December 2009 16:43

Thanks for the help but I still can't open any PHP file, even by double-clicking. No matter what I do, I get the File Open and Save dialog box. Although clicking phpinfo() at http://localhost/ works fine. I don't dare uninstall XAMPP because I've created a lot of data in MySql and don't want to lose it. Also, I don't understand the apache configuration file enough to tinker with it, I'm new to PHP development. Can anyone recommend a book that deals with configuring Apache, PHP, and MySql in detail so I can figure out what is wrong?
drh3010
 
Posts: 4
Joined: 12. December 2009 06:55

Re: File Download Dialog when opening PHP files

Postby Wiedmann » 12. December 2009 17:37

I still can't open any PHP file, even by double-clicking. No matter what I do,

You can't open a php file (or in this case a html file too) with a double click in explorer or using the "file open" dialog in your browser.
--> XAMPP is a server, thus you have to use "http://localhost/foo.php" in the browsers address bar.

Additionally we are only able to help:
- if we know the filename and directory where you have stored your PHP file
- and with URI you are using in your browsers address bar.

(the relevant entry in the "error.log" can also help)

BTW:
This is the first exercise in the book PHP and MySQL Web Development, Addison/Wesley press.

Maybe you want start with a simple "Hello World" script from the PHP manual. Just to see how a webserver is working?

Can anyone recommend a book that deals with configuring Apache, PHP, and MySql in detail so I can figure out what is wrong?

You don't need a book about how to configure a webserver. Maybe a book about: how to use a browser to access a file which stored on a webserver.
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: File Download Dialog when opening PHP files

Postby drh3010 » 12. December 2009 18:39

Thanks Weidmann for leading me down a different path to debug the problem.

I fixed the problem by adding the following to the httpd.conf:
(I found the solution in the Beginning PHP and MySQL E-Commerce book)

<IfModule alias_module>
Alias /test/ "G:/Websites/Tests/Bob's Auto Parts/"
Alias /test "G:/Websites/Tests/Bob's Auto Parts"
</IfModule>

<Directory "G:/Websites/Tests/Bob's Auto Parts">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>

Now everything works if I access http://localhost/test/orderform.html

What threw me off is Dreamweaver's "File > Preview In Brower > IExplorer" menu choice. That would send the browser to "G:/Websites/Tests/Bob's Auto Parts/orderform.html" which will not load PHP files.
drh3010
 
Posts: 4
Joined: 12. December 2009 06:55

Re: File Download Dialog when opening PHP files

Postby Izzy » 12. December 2009 22:25

There was also a solution in a very recent similar post had you provided the correct details in the first place:
viewtopic.php?f=16&t=38428
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 75 guests