在php中提交表单时出错

时间:2017-11-13 14:57:55

标签: javascript php html http

看来我的信息没有正确放入POST阵列。我是php的新手,所以我不太清楚为什么。我不知道你们都需要什么其他信息,所以我只是放置代码和错误信息。您可以提供的任何帮助/建议将不胜感激。

这是渲染后的表格。 enter image description here

这是我提交后的错误。

The error I get after I select submit

这是代码片段。我没有包括所有的HTML。我可能是因为我需要抛弃php并在java中编写内容。意见表示欢迎。

        <h2 class="tgminix-padding-large" style="margin:auto;max-width:1000px">Calculating Total Percent Impedance Upstream of the Motor</h2>
    <hr class="tgminix-border-grey" style="margin:auto;width:80%">
    <p><span class="error">* Required Field</span></p>
    <form method="post" action="<?php echo htmlspecialcharachars($_SERVER["PHP_SELF"]);?>
          High Side Busbar Impedance (Real): <input type="float" name="SubstationHighsideEqivImpedanceR">
          <span class="error"> <?php echo $subImpedanceError;?></span>
          <br><br>
           High Side Busbar Impedance (Imaginary): <input type="float" name="SubstationHighsideEqivImpedanceI">
          <span class="error"> <?php echo $subImpedanceError;?></span>
          <br><br>
           Low Side Busbar Impedance (Real): <input type="float" name="SubstationLowsideEquivImpedanceR">
          <span class="error"><?php echo $subImpedanceError;?></span>
          <br><br>
          Low Side Busbar Impedance (Imaginary): <input type="float" name="SubstationLowsideEquivImpedanceI">
          <span class="error"><?php echo $subImpedanceError;?></span>
          <br><br>
          Motor Starting Power Factor: <input type="float" name="MotorStartingPowerFactor_num">
          <span class="error"><?php echo $subImpedanceError;?></span>
          <br><br>
          <input type="submit" value="Submit">
    </form>
  <?php
    /* Locked Rotor Constants Array 
    $MotorLockedRotorConstants = array(
            array("NEMA Code Letter","Mid-Value Constant")
            array("A",1.6)
            array("B",3.3)
            array("C",3.8)
            array("D",4.3)
            array("E",4.7)
            array("F",5.3)
            array("G",5.9)
             array("H",6.7)
            array("J",7.5)
            array("K",8.5)
            array("L",9.5)
            array("M",10.6)
            array("N",11.8)
            array("P",13.2)
            array("R",15.0)
            array("S",17.1)
            array("T",19.0)
            array("U",21.5)
            array("V",25));*/
        if ($_POST){
            $SubstationHighsideEqivImpedance_real = $_POST["SubstationHighsideEqivImpedanceR"];
            $SubstationHighsideEquivImpedance_imaginary = $_POST["SubstationHighsideEqivImpedanceI"];
            $SubstationLowsideEquivImpedance_real = $_POST["SubstationLowsideEquivImpedanceR"];
            $SubstationLowsideEquivImpedance_imaginary = $_POST["SubstationLowsideEquivImpedanceI"];

            $MotorStartingPowerFactor = $_POST["MotorStartingPowerFactor_num"];

            $SubstationPercentImpedance = "";
            $TEMP_X_perc = $TEMP_R_perc = "";
            $TEMP_X_perc = $SubstationLowsideEquivImpedance_imaginary + 0.333333 * $SubstationHighsideEquivImpedance_imaginary;
            $TEMP_R_perc = $SubstationLowsideEquivImpedance_real + 0.33333 * $SubstationHighsideEqivImpedance_real;
            $RAD_ANGLE_TEMP = $MotorStartingPowerFactor*(pi()/180);
            $DEG_ANGLE_TEMP_cos = (180/pi()) * cos($RAD_ANGLE_TEMP);
            $DEG_ANGLE_TEMP_sin = (180/pi()) * sin($RAD_ANGLE_TEMP);
            $SubstationHisideImpedancePercent = ($TEMP_R_perc * $DEG_ANGLE_TEMP_cos) + ($TEMP_X_perc * DEG_ANGLE_TEMP_sin);
        } else {
            echo "There's nothing in POST. srry"
        }
       ?>
    <p class="tgminix-padding-large" style="margin:auto;max-width:1000px">
        The Substation Impedance is: <?php echo $SubstationHisideImpedancePercent; ?>
        <br>
        The Substation Impedance is: <?php echo $TEMP_R_perc; ?> $ + \mathbf{i}$ <?php echo $TEMP_X_perc; ?>
    </p> 

如果这太模糊,请告诉我。

1 个答案:

答案 0 :(得分:0)

    REPLACE
    <form method="post" action="<?php echo htmlspecialcharachars($_SERVER["PHP_SELF"]);?>
    WITH
    <form method="post" action="<?php echo htmlspecialcharachars($_SERVER["PHP_SELF"]);?>">