0

下面是我在表单页面上创建的代码片段。表单输入显示了 $adjustedGrossIncome、$personalExemptions 的正确变量以及可退还积分前应缴税款的计算,但是当我尝试回显 $birthYear 时,php 死了。任何提示我做错了什么?

<?php

    $filingStatus = $_Post['filingStatus'];
    $birthYear = $_Post['birthYear'];
    $dependents = $_Post['dependents'];
    $children = $_POST['children'];
    $exemptions = $_POST['exemptions'];
    $income = $_POST['income'];
    $investments = $_POST['investments'];
    $retirement = $_POST['retirement'];
    $property = $_POST['property'];

        $adjustedGrossIncome = $income + $investments + $retirement;

        $personalExemptions = ($exemptions * 3950);


?>

<form id="form1" name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
  <fieldset style="width:500px;">
    <legend>Filing Status</legend>
    <p>
      <label>
        <input type="radio" name="filingStatus" value="married" id="filingStatus" />
        Married filing jointly</label>
      <br />
      <label>
        <input type="radio" name="filingStatus" value="single" id="filingStatus" />
        Single or Head of Household</label>
    </p>
  </fieldset>
  <p>
    <label>Birth Year
  <select name="birthYear" id="birthYear">
    <option>Select Year</option>
    <option value="1923">1923</option>
    <option value="1924">1924</option>
    <option value="1925">1925</option>
    <option value="1926">1926</option>
    <option value="1927">1927</option>
    <option value="1928">1928</option>
    <option value="1929">1929</option>
    <option value="1930">1930</option>
    <option value="1931">1931</option>
    <option value="1932">1932</option>
    <option value="1933">1933</option>
    <option value="1934">1934</option>
    <option value="1935">1935</option>
    <option value="1936">1936</option>
    <option value="1937">1937</option>
    <option value="1938">1938</option>
    <option value="1939">1939</option>
    <option value="1940">1940</option>
    <option value="1941">1941</option>
    <option value="1942">1942</option>
    <option value="1943">1943</option>
    <option value="1944">1944</option>
    <option value="1945">1945</option>
    <option value="1946">1946</option>
    <option value="1947">1947</option>
    <option value="1948">1948</option>
    <option value="1949">1949</option>
    <option value="1950">1950</option>
    <option value="1951">1951</option>
    <option value="1952">1952</option>
    <option value="1953">1953</option>
    <option value="1954">1954</option>
    <option value="1955">1955</option>
    <option value="1956">1956</option>
    <option value="1957">1957</option>
    <option value="1958">1958</option>
    <option value="1959">1959</option>
    <option value="1960">1960</option>
    <option value="1961">1961</option>
    <option value="1962">1962</option>
    <option value="1963">1963</option>
    <option value="1964">1964</option>
    <option value="1965">1965</option>
    <option value="1966">1966</option>
    <option value="1967">1967</option>
    <option value="1968">1968</option>
    <option value="1969">1969</option>
    <option value="1970">1970</option>
    <option value="1971">1971</option>
    <option value="1972">1972</option>
    <option value="1973">1973</option>
    <option value="1974">1974</option>
    <option value="1975">1975</option>
    <option value="1976">1976</option>
    <option value="1977">1977</option>
    <option value="1978">1978</option>
    <option value="1979">1979</option>
    <option value="1980">1980</option>
    <option value="1981">1981</option>
    <option value="1982">1982</option>
    <option value="1983">1983</option>
    <option value="1984">1984</option>
    <option value="1985">1985</option>
    <option value="1986">1986</option>
    <option value="1987">1987</option>
    <option value="1988">1988</option>
    <option value="1989">1989</option>
    <option value="1990">1990</option>
    <option value="1991">1991</option>
    <option value="1992">1992</option>

  </select>
    </label>
  </p>
  <p>
    <label>Number of Dependents (not including taxpayer and spouse if applicable
      <input type="text" name="dependents" id="dependents" />
    </label>
  </p>
  <p>
    <label>Number of Children under 18
      <input type="text" name="children" id="children" />
    </label>
  </p>
  <p>
    <label>Total number of exemptions
      <input type="text" name="exemptions" id="exemptions" />
    </label>
  </p>
  <p>
    <label>Total Wages/Salary
      <input type="text" name="income" id="income" />
    </label>
  </p>
  <p>
    <label>Investment income (interest, dividends, capital gains)
      <input type="text" name="investments" id="investments" />
    </label>
  </p>
  <p>
    <label>Retirement income (pension, IRA, 401(k), etc.)
      <input type="text" name="retirement" id="retirement" />
    </label>
  </p>
  <p>
    <label>Annual property taxes paid on primary residence and/or annual rent
      <input type="text" name="property" id="property" />
    </label>
  </p>
  <p>
    <input type="submit" name="submit" id="submit" value="Calculate Net Tax Liability for 2013" />
    <input type="reset" name="reset" id="reset" value="Reset Form"  onClick="window.location.reload()" />
  </p>
</form>



<p>Adjusted Gross Income: $<?php echo($adjustedGrossIncome); ?></p>
<p>Personal Exemptions: $<?php echo($personalExemptions); ?></p>
<p>Tax Due Before Refundable Credits: $<?php echo(($adjustedGrossIncome - $personalExemptions) * .0425); ?></p>
<p><?php echo($birthYear); ?></p>
4

1 回答 1

1

全部$_Post改成大写$_POST

这被称为超全局并且必须是大写的。

更多关于 superglobals 的信息可以在 PHP.net 网站上找到

于 2013-10-15T19:01:50.727 回答