Jump to content

PHP files won't run, but try to download


Recommended Posts

I am trying to set up PHP with Apache, and I can not get the installation to work properly.

 

I am using an html form page from the Apache root using <http://localhost/ simpleform.html>, to call a PHP script (see below), but instead of executing the script, it prompts me to download the file. If I download the file, I get the entire PHP script file, exactly as it is. Running the PHP file from an html file, and getting the download dialog, if I choose “open” the dialog box goes away, and the PHP file does nothing.

 

When I execute this PHP file directly, by itself from the root using http://localhost/send_simpleform.php, it seems to work properly.  All other PHP files also work properly using the same direct method.

 

I have tried a variety of other sample html files using PHP scripts, all with the same results, so I do not think the problem is with the actual code, but with the set-up.

 

I have uninstalled and re-installed both Apache and PHP several times, using different installation parameters, all with the same results.

 

I am using the latest version of Apache 2.2, and PHP version 5.2.1, on Windows XP-SP2, set up as a localhost only to be used for developing the html/PHP code.

 

Any ideas how to get this to work?

 

Details ---------------------------

 

I have installed PHP manually, after Apache using the typical instructions posted on the PHP website, and modified the Apache configuration httpd.conf file as follows:

 

LoadModule php5_module "c:/php/php5apache2_2.dll"

AddType application/x-httpd-php .php

 

# configure the path to php.ini

PHPIniDir "C:/php"

 

I am using the example from the book I am learning with as follows:

 

HTML code for simpleform.html

<html>
<head>
<title>A simple HTML form</title>
</head>
<body>
<form action="send_simpleform.php" method="POST">
<p><strong>Name:</strong><br/>
<input type="text" name="user"></p>
<p><strong>Message:</strong><br/>
<textarea name="message" rows="5" cols="40"/></textarea></p>
<p><input type="submit" value="send"/></p>
</form>
</body>
</html>

 

PHP File send_simpleform.php

<?php
echo "<p>Welcome <b>".$_POST["user"]."</b>!</p>";
echo "<p>Your message is:<br/><b>".$_POST["message"]."</b></p>";
?>

Link to comment
https://forums.phpfreaks.com/topic/48946-php-files-wont-run-but-try-to-download/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.