being prompted to download .php file instead of just opening

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

being prompted to download .php file instead of just opening

Postby jgilliand » 25. November 2008 23:43

hello all,

newbie to xampp. i am able to open a .php file as my default page but when i try to open a .php file any other way, i get
"You have chosen to download a file from this location.

test.php from local host

what would yo like to do with this file?"
-Open...
-Save...
what do i need to do to fix this problem?
thank you in advance for help.
jgilliand
 
Posts: 6
Joined: 25. November 2008 23:34

Postby glitzi85 » 26. November 2008 00:00

How do you try to open this file? And what do you mean with default page?

glitzi
User avatar
glitzi85
 
Posts: 1920
Joined: 05. March 2004 23:26
Location: Dahoim

Postby jgilliand » 26. November 2008 00:17

glitzi85,

either though a link referencing test.php or by file>open>browse....

by default page i mean
<ifmodule dir_module>
DirectoryIndex test.php
</IfModule>

thank you
jgilliand
 
Posts: 6
Joined: 25. November 2008 23:34

Postby glitzi85 » 26. November 2008 00:28

jgilliand wrote:either though a link referencing test.php or by file>open>browse....

That's what not working with PHP. If you open a PHP File in that way it is read from Harddisk. PHP needs to be parsed through the PHP Interpreter (which is running as a Module of the Apache Webserver).

Because of this you have to place your PHP-Files inside the htdocs folder and call them via http://localhost/filename.php

glitzi
User avatar
glitzi85
 
Posts: 1920
Joined: 05. March 2004 23:26
Location: Dahoim

Postby jgilliand » 26. November 2008 00:31

but why is it not working when i try opening the .php file via a link?
jgilliand
 
Posts: 6
Joined: 25. November 2008 23:34

Postby glitzi85 » 26. November 2008 00:40

Please show me the Link. If the Link looks like this:

Code: Select all
<a href="file:\\\C:/xampp/htdocs/file.php">Link</a>


Then it would be the same as open the file via File -> Open File...

Your Link must look like this:

Code: Select all
<a href="http://localhost/file.php">Link</a>


on the other hand, if you use such links you will get in troubles when you upload them onto an public server, as localhost always refers to the own computer, so most of your visitors will not see anything, the others will see their own local Webserver ;-)

You can use it also in this way:

Code: Select all
<a href="/file.php">Link</a>


but only if the file which contains the link is in the same directory as file.php and it is called via the Webserver too!

For example:

test.php:
Code: Select all
<html>
<head>
<title>Test</title>
</head>
<body>
<a href="/output.php?link=1">Link 1</a><br />
<a href="/output.php?link=2">Link 2</a>
</body>
</html>


output.php:
Code: Select all
<?php
if(empty($_GET['link'])){
 header("Location: /test.php");
 exit();
}?>
<html>
<head>
<title>Follow Up</title>
</head>
<body>
You clicked Link No. <?php echo $_GET['link']; ?>
</body>
</html>


Put both files in C:\xampp\htdocs (or wherever you installed XAMPP) and call http://localhost/test.php

glitzi
User avatar
glitzi85
 
Posts: 1920
Joined: 05. March 2004 23:26
Location: Dahoim

Postby jgilliand » 26. November 2008 00:50

my link is
<a href = "test.php">test.php</a>

and test.php is in /xampp/htdocs
jgilliand
 
Posts: 6
Joined: 25. November 2008 23:34

Postby jgilliand » 26. November 2008 01:05

also getting error message when entering http://localhost/test.php in address bar:

"You have chosen to download a file from this location.

test.php from local host

what would yo like to do with this file?"
-Open...
-Save...

so it looks like the only way i can open a .php file is if it is configured to be my default page
jgilliand
 
Posts: 6
Joined: 25. November 2008 23:34

Postby jgilliand » 26. November 2008 05:33

was running ie5. issue was resolved by installing firefox. didn't have to make any new changes.
jgilliand
 
Posts: 6
Joined: 25. November 2008 23:34

Postby glitzi85 » 26. November 2008 15:11

jgilliand wrote:was running ie5. issue was resolved by installing firefox. didn't have to make any new changes.

IE5 :shock: We are nearly 3 Versions ahead!
User avatar
glitzi85
 
Posts: 1920
Joined: 05. March 2004 23:26
Location: Dahoim


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 170 guests