-1

I have a simple form and php file. When I click submit it just pulls up a plain text file with the contents of resources.php. Why would this be happening?

index.html

<html>
<head>
</head>
<body>

    <form action="resources.php" method='POST'>

        <input type="text"  placeholder="Name" name="name"><br>
        <input type="text"  placeholder="Organization" name="organization"><br>
        <input type="email" placeholder="E-Mail" name="email"><br>
        <input type="text"  placeholder="Street Address" name="streetaddress"><br>
        <input type="text"  placeholder="Phone Number" name="phonenumber"><br>
        <input type="text"  placeholder="What is three plus four?" name="human"><br>

        <input type="submit">

</form>
</body>
</html>

and the resources.php file...

<html>
<head></head>
<body>

<?php

    echo '<pre>'.$_POST.'<pre>';

?>

</body>
</html>

Thanks.

broinjc
  • 2,619
  • 4
  • 28
  • 44
  • 1
    If you're seeing the PHP code *on the client* that means your web server isn't processing the code. You would likely need to re-install and/or re-configure PHP on your server. – David Mar 07 '14 at 20:55
  • 2
    Your server isn't configured to execute PHP, or you've saved your files as .html, which aren't executed as PHP either. Plus, `echo $_POST` will NOT work. you'll just get the literal word `Array` as output. – Marc B Mar 07 '14 at 20:56
  • 2
    Does your webserver recognizing and executing PHP files? If you're using Apache, for instance, you'll need to have a line like `AddType x-httpd-php .php ` somewhere in your conf and the libphp.so file will need to be available as a module. – stakolee Mar 07 '14 at 20:57
  • @MarcB `print_r($_POST)` – broinjc Mar 07 '14 at 21:20

1 Answers1

2

Here are possible answers to your problem:

  1. WEB server is not processing your PHP code correctly because php is not installed or misconfigured.
  2. You're not using the web server at all. Make sure to load your pages from localhost (or whatever your server is) and not from the file itself ex: localhost/path/to/index.html and not c://program files...
greg0ire
  • 22,714
  • 16
  • 72
  • 101
Cedric Guindon
  • 354
  • 1
  • 12