2

When I submit this form it downloads the php script it refers to:

<form action="insertcustomer.php" method="post" class="myform">
<p>
    Name: &nbsp; <input type="text" name="name" size="20"/>
</p>
<p>
    Address: &nbsp; <input type="text" name="addr" size="40"/></p>
<p>
    City: &nbsp; <input type="text" name="city" size="20"/>
    State: &nbsp; <input type="text" name="state" size="3"/>
    Phone: &nbsp; <input type="text" name="phone" size="15"/>
</p>
<p>
    Account Balance: &nbsp; <input type="text" name="acct_balance" size="13"/>
</p>
<p class="bttn">
    <input class="b" type="submit" name="query" value="Insert Customer"/>&nbsp;
    <input class="b" type="reset" name="reset" value="Clear Form"/>
</p>

</form>

Insertcustomer.php:

$name = $_POST['name'];
$addr = $_POST['address'];
$city = $_POST['ccity'];
$state = $_POST['cstate'];
$phone = $_POST['phone'];
$acct_balance = $_POST['acct_balance'];

Is there something wrong with the code? I have followed all steps mentioned in this article, but every time I click on the submit button, it downloads the php file. I apologize in advance as I am fairly new to php.

3
  • 1
    You need to wrap your page in <?php ... ?>. Also, are you hosting the php script on a webserver that supports PHP? If you're perhaps loading it directly from disk (as we often do during development) then nothing is in place to process the PHP code. Commented Jun 9, 2012 at 2:10
  • Create a phpinfo.php file with the following contents: <?php phpinfo(); ?>. If you see a list of PHP information, PHP is configured properly. Commented Jun 9, 2012 at 2:47
  • Sorry forgot to mention it is wrapped in <?php ?>. I have loaded and set up apache (going to localhost returns the "It works!" page). Commented Jun 9, 2012 at 3:28

1 Answer 1

3
  • Make sure your code is wrapped in <?php and ?>
  • Does your server support PHP?
  • Is your server configured properly?
Sign up to request clarification or add additional context in comments.

1 Comment

Update: I think it was a problem with the directory I was storing the files in. I now have them in /library/webserver/documents. I also created the phpinfo.php file and received the php output so i know php is running. Now It doesn't try to download the file, instead I get the error message "Connection Failed: No such file or directory"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.