0

When I click a link a simple HTML web form linked to a php file, the browser is downloading the PHP file rather than executuing it in the browser. Any dieas?

3
Contributors
10
Replies
31
Views
4 Years
Discussion Span
Last Post by broj1
0

Here's the html code fomr the book "PHP and MySQL Web Development"

<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>How did you find Bob's?</td>
  <td><select name="find">
        <option value = "a">I'm a regular customer</option>
        <option value = "b">TV advertising</option>
        <option value = "c">Phone directory</option>
        <option value = "d">Word of mouth</option>
      </select>
  </td>
</tr>
<tr>
  <td colspan="2" align="center"><input type="submit" value="Submit Order"></td>
</tr>
</table>
</form>
</body>
</html>
0

Do a simple test. Create a PHP file (say test.php) with only the following content and check in the browser what happens when you open it.

<?php
phpinfo();
?>

The phpinfo() function should display all sorts of info about PHP if PHP is installed and configured properly on your server. If not then you have to check the installation.

0

I have tested this in my environment (Ubuntu 12.10, Apache, Firefox 19.0) and it displays php file normaly.

What happens if you navigate your browser to the php file directly?

0

It work fine when I point the url streight to the php file. localhost/bail.php -> outputs Hello World

When the same file is called from an html form the browser downloads bail.php to my /home/downloads directory.

0

A few 'stupid' questions (I am blindly guessing now):

  • if you download the php file, what is the contents of it?
  • have you tried this in different browsers (FF, Chrome, IE)?
  • do you use Google sitemaps plugin?
  • have you been changing the php config?
  • how much memory does php have (see in phpinfo)
  • do you use a .htaccess file

Edited by broj1

0

Another ideas:
1. change method to GET and see if it works
2. specify enctype="application/x-www-form-urlencoded" for the form (which is default anyway)

 <form action="processorder.php" method="post" enctype="application/x-www-form-urlencoded">

Edited by broj1

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.