我想發佈一個表單到$ wp_session這是工作正常 - 但是當我再次執行它覆蓋我放在那裏的數組,首先,我需要數組像收集/購物籃一樣進行建設。
我的形式:
<form class="form1" method="post" action="" id="form1">
<fieldset>
<ul>
<label for="name">Exercise ID</label><span>
<input type="text" name="ExerciseID" placeholder="Exercise ID" class="required" role="input" aria-required="true"/></span>
<label for="name">Exercise Reps</label><span>
<input type="text" name="Sets" placeholder="Sets" class="required" role="input" aria-required="true"/></span>
<label for="name">Exercise Reps</label><span>
<input type="text" name="Reps" placeholder="Sets" class="required" role="input" aria-required="true"/></span>
<input class="submit .transparentButton" value="Next" type="submit" name="Submit"/>
</ul>
<br/>
</fieldset>
</form>
而且PHP:
<?php
global $wp_session;
if (isset($_POST['Submit'])) {
$wp_session['collection'] = array($POST['ExerciseID'],$_POST['Sets'],$POST['Reps']);
}
print_r($wp_session);
?>
提前非常感謝。
首先,數組中缺少一些下劃線($ POST ['ExerciseID'],$ _ POST ['Sets'],$ POST ['Reps'])'try'array($ _ POST ['ExerciseID' ],$ _ POST ['Sets'],$ _ POST ['Reps'])'這些是超全局變量,其中99%需要變爲'$ _XXX' –