Wordpress插件使用php方法="post"不传递值


Wordpress plugin using php method="post" not passing values

我正在使用php为Wordpress制作一个插件,该插件使用post方法获得平方英尺和价格,然后将它们相乘并输出值。php代码在我的本地主机上执行时很好,但在wordpress上执行时总是给我0。

我已经尝试给我的变量唯一的名称,我已经尝试有动作设置为",实际的url,页码,并使用php来获取页头。我看到了几个类似于我的关于堆栈溢出的问题,但我找到的建议解决方案都不适合我。如有任何帮助,不胜感激。

<?php

//WordPress Hooks 
add_shortcode('jcalc','includeJonnyCalculatorCustom'); 
if (isset($_POST['jcalcthe_squarefeet'])) 
{
    $jcalcthe_squarefeet = $_POST['jcalcthe_squarefeet'];
}
if (isset($_POST['jcalcthe_price']))
{
    $jcalcthe_price = $_POST['jcalcthe_price'];
}
function includeJonnyCalculatorCustom()
{
?>
<p> some text here...
</p>
<?php
if ( isset($_POST['jcalc_calculate']) )
{
$jcalcthe_estimate = ( jcalcthe_squarefeet * jcalcthe_price );
$jcalcthe_estimate = number_format( $jcalcthe_estimate, 2 );
?>
<div>
<form method="post" action=''>
<p> The estimate for your inspection is $
<?php echo $jcalcthe_estimate; ?>
</p>
<button> Back to calculator </button>
</form>
</div>
<?php
}
else
{
?>
<div>
<form method="post" action=''>
<h3> Estimate Calculator </h3>
<label> Square footage of your home: </label>
<input name="jcalcthe_squarefeet" value="<?php echo $jcalcthe_squarefeet ?>"> </input><br /><br />
<label> Price per square foot: </label><br />
<select name="jcalcthe_price" value="<?php echo $jcalcthe_price ?>" style="width: 160px;">
<option value=".15" > $0.15 </option>
<option value=".2" > $0.20 </option>
</select><br /><br />
<button type="submit" style="width: 160px; background-color: lightgrey;"            name="jcalc_calculate"> Calculate estimate </button>
</form>
</div>
<?php
}
}
?>

在短代码中包含您的逻辑

function includeJonnyCalculatorCustom() {
    if ( isset($_POST['jcalc_calculate']) ) {

        if (isset($_POST['jcalcthe_squarefeet'])) {
           $jcalcthe_squarefeet = $_POST['jcalcthe_squarefeet'];
        }
        if (isset($_POST['jcalcthe_price'])) {
           $jcalcthe_price = $_POST['jcalcthe_price'];
       }
       $jcalcthe_estimate = ( $jcalcthe_squarefeet * $jcalcthe_price );
       $jcalcthe_estimate = number_format( $jcalcthe_estimate, 2 );
       // Rest code here
   }
    // Rest Code
    //.........