php - wp_session variables being overwritten by $_POST -


i trying post form $wp_session working fine - when perform again overwrites array have put there in first place, need arrays carry on building collection / shopping basket.

my form:

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

and php:

<?php  global $wp_session;  if (isset($_post['submit'])) {  $wp_session['collection'] = array($post['exerciseid'],$_post['sets'],$post['reps']);  }  print_r($wp_session);  ?>  

many in advance.

to have basket, have add products array:

<?php  global $wp_session;  if (isset($_post['submit'])) {  $wp_session['collection'][] = array($_post['exerciseid'],$_post['sets'],$_post['reps']);  }  print_r($wp_session);  ?>  

you may want organize array exerciseid, can add quantity. advice create objects, more flexible arrays


Comments

Popular posts from this blog

Change the color of an oval at click in Java AWT -

c# - Unity IoC Lifetime per HttpRequest for UserStore -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -