提交表单下载 php 脚本


Submit form downloads php script

当我提交此表单时,它会下载它所引用的php脚本:

<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>

插入客户.php:

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

代码有问题吗?我已经遵循了本文中提到的所有步骤,但是每次单击提交按钮时,它都会下载php文件。我提前道歉,因为我对 php 相当陌生。

  • 确保代码包装在<?php?>
  • 您的服务器支持 PHP 吗?
  • 您的服务器配置是否正确?