PHP script code is displayed instead of executed
Moderator: General Moderators
PHP script code is displayed instead of executed
Hello everybody,
I am a newbie in php and this is my first post to the php community.
I installed Apache 1.3 and php 4 (I got both of them on a CD together with a book about MySQL and php) on Win XP and started to learn php.
The installation of php has been tested with the command http://localhost/info.php and the known php configuration text was displayed.
This means that a php installation was successful. Whenever I start a php script directly in form http://localhost/xxx.php the script works fine.
The problem appears when I want to use a form together with a php script. I prepared a simple form with one text field and submit button:
<form action="action.php" method="post">
<p>Your name: <input type="text" name="name" /></p>
<p><input type="submit" /></p>
</form>
The action.php is:
Hello <?php echo $_POST['name']; ?>.
If I submit the name (for example "kekec", then the browser shoes the above mentioned source code of the php script instead of "Hello kekec".
Any idea or advice is very appreciated.
kekec
I am a newbie in php and this is my first post to the php community.
I installed Apache 1.3 and php 4 (I got both of them on a CD together with a book about MySQL and php) on Win XP and started to learn php.
The installation of php has been tested with the command http://localhost/info.php and the known php configuration text was displayed.
This means that a php installation was successful. Whenever I start a php script directly in form http://localhost/xxx.php the script works fine.
The problem appears when I want to use a form together with a php script. I prepared a simple form with one text field and submit button:
<form action="action.php" method="post">
<p>Your name: <input type="text" name="name" /></p>
<p><input type="submit" /></p>
</form>
The action.php is:
Hello <?php echo $_POST['name']; ?>.
If I submit the name (for example "kekec", then the browser shoes the above mentioned source code of the php script instead of "Hello kekec".
Any idea or advice is very appreciated.
kekec
-
Charles256
- DevNet Resident
- Posts: 1375
- Joined: Fri Sep 16, 2005 9:06 pm
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
I will bet it'd show the code..
I'm going to guess your book told you to install it via the CGI handler, which then limits PHP execution to a particular handling directory and is slower than running PHP as a module. If so, install php as a module instead (following the instructions found in the zip, at least, download)
I'm going to guess your book told you to install it via the CGI handler, which then limits PHP execution to a particular handling directory and is slower than running PHP as a module. If so, install php as a module instead (following the instructions found in the zip, at least, download)
feyd, you will loose
.
Running action.php alone shows
Hello .
instead of "Hello kekec ." which would be correct, or a source code.
I copied the php directory from the CD, then modified php.ini (doc_root, extension_dir, display_errors, enabled php_gd.dll), copied php4ts.dll into system32 directory.
Finally I added the following lines to the httpd.conf:
LoadModule php4_module c:/web/php/sapi/php4apache.dll
AddType application/x-httpd-php .php
AddType application/x-httpd-php .php3
AddType application/x-httpd-php .php4
As far as I know (well, I am new here) this a standard php installation. Perhaps something is still missing.
kekec
Running action.php alone shows
Hello .
instead of "Hello kekec ." which would be correct, or a source code.
I copied the php directory from the CD, then modified php.ini (doc_root, extension_dir, display_errors, enabled php_gd.dll), copied php4ts.dll into system32 directory.
Finally I added the following lines to the httpd.conf:
LoadModule php4_module c:/web/php/sapi/php4apache.dll
AddType application/x-httpd-php .php
AddType application/x-httpd-php .php3
AddType application/x-httpd-php .php4
As far as I know (well, I am new here) this a standard php installation. Perhaps something is still missing.
kekec
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
Code: Select all
<form action="action.php" method="post">
<input type="submit" />
</form>To be completely honest, I have no clue why POST requests are getting selectively dropped. If you're a little impatient, you can uninstall and then install straight from the horses mouth...
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US