How do i fill an php array with my session and other variables?js












-1














Good day experts!



I am stuck on a problem.
This is my function.php



 function tbl_questions() {
global $mysqlhost, $mysqluser, $mysqlpwd, $mysqldb;



$connection=mysqli_connect($mysqlhost, $mysqluser, $mysqlpwd) or die ("Verbindungsversuch fehlgeschlagen");
mysqli_select_db($connection, $mysqldb) or die("Konnte die Datenbank nicht waehlen.");
$sql_tbl_questions = "SELECT * FROM `questions` where istAktiv='1'";
$quest_query = mysqli_query($connection, $sql_tbl_questions) or die("Anfrage nicht erfolgreich");

$i = 0;

while ($question = mysqli_fetch_array($quest_query)) {
$i++;
echo '<tr>';
echo '<th>'.$i.'</th>';
echo '<th>'.$question['question'].'</th>';
echo '<th class="text-center"><input type="radio" name="'.$question['dimension'].'_question_'.$question['id'].'" value="0" required></th>';
echo '<th class="text-center"><input type="radio" name="'.$question['dimension'].'_question_'.$question['id'].'" value="2.5"></th>';
echo '<th class="text-center"><input type="radio" name="'.$question['dimension'].'_question_'.$question['id'].'" value="5"></th>';
echo '<th class="text-center"><input type="radio" name="'.$question['dimension'].'_question_'.$question['id'].'" value="7.5"></th>';
echo '<th class="text-center"><input type="radio" name="'.$question['dimension'].'_question_'.$question['id'].'" value="10"></th>';
echo '</tr>';
$dimensions = $question['dimension'];
}
echo '<tr>';
echo '<th></th>';
echo '<th>Kommentar/Ihre Anmerkung</th>';
echo '<th class="text-center" colspan=5><textarea rows=3 cols=50 name="Kommentar"></textarea></th>';
echo '</tr>';

echo '<input type="hidden" name="gesamt" value="'.$i.'">';
echo '<input type="hidden" name="dimensions" value="'.$dimensions.'">';
echo '<input type="hidden" name="size" value="'.$_POST['size'].'">';
echo '<input type="hidden" name="branche" value="'.$_POST['branche'].'">';
//echo $_POST['size'];
//echo $_POST['branche'];
}`


That function.php is saving data from an questionaire which is containing values.
My problem is as easy as complex. I am moving through this questionaire through an javascript:






function senden(goBack){

if(goBack==0)
{
document.getElementById('page').value++;
if( document.getElementById('page').value >9){
document.getElementById('submitForm').action='auswertung.php';

}
document.getElementById('submitForm').submit();
}
else
{
document.getElementById('page').value--;
if( document.getElementById('page').value <1){
document.getElementById('submitForm').action='branche.php';

}
document.getElementById('submitForm').submit();
}

}





And of course some html for the buttons:






  <input type="hidden" id="page" name="page" value="<?php echo $page; ?>" />
<button type="button" id="doubleButtons" class="btn btn-default" onclick="senden(1)">Zurück</button>
<button type="button" id="doubleButtons" class="btn btn-default" onclick="senden(0)"><?php echo $page==9?"FDC Auswerten":"Weiter";?></button>





The questionnaire got those radio buttons which i am talking about, a button for next and a button for back.



My problem is : If i am filling my questionnaire and press the back button, the filled stuff is gone!
So my idea was to save everything into an array, but can you give me a hint how i have to do it?



I hope my question is quite clear, if not, please excuse me and let me know!










share|improve this question





























    -1














    Good day experts!



    I am stuck on a problem.
    This is my function.php



     function tbl_questions() {
    global $mysqlhost, $mysqluser, $mysqlpwd, $mysqldb;



    $connection=mysqli_connect($mysqlhost, $mysqluser, $mysqlpwd) or die ("Verbindungsversuch fehlgeschlagen");
    mysqli_select_db($connection, $mysqldb) or die("Konnte die Datenbank nicht waehlen.");
    $sql_tbl_questions = "SELECT * FROM `questions` where istAktiv='1'";
    $quest_query = mysqli_query($connection, $sql_tbl_questions) or die("Anfrage nicht erfolgreich");

    $i = 0;

    while ($question = mysqli_fetch_array($quest_query)) {
    $i++;
    echo '<tr>';
    echo '<th>'.$i.'</th>';
    echo '<th>'.$question['question'].'</th>';
    echo '<th class="text-center"><input type="radio" name="'.$question['dimension'].'_question_'.$question['id'].'" value="0" required></th>';
    echo '<th class="text-center"><input type="radio" name="'.$question['dimension'].'_question_'.$question['id'].'" value="2.5"></th>';
    echo '<th class="text-center"><input type="radio" name="'.$question['dimension'].'_question_'.$question['id'].'" value="5"></th>';
    echo '<th class="text-center"><input type="radio" name="'.$question['dimension'].'_question_'.$question['id'].'" value="7.5"></th>';
    echo '<th class="text-center"><input type="radio" name="'.$question['dimension'].'_question_'.$question['id'].'" value="10"></th>';
    echo '</tr>';
    $dimensions = $question['dimension'];
    }
    echo '<tr>';
    echo '<th></th>';
    echo '<th>Kommentar/Ihre Anmerkung</th>';
    echo '<th class="text-center" colspan=5><textarea rows=3 cols=50 name="Kommentar"></textarea></th>';
    echo '</tr>';

    echo '<input type="hidden" name="gesamt" value="'.$i.'">';
    echo '<input type="hidden" name="dimensions" value="'.$dimensions.'">';
    echo '<input type="hidden" name="size" value="'.$_POST['size'].'">';
    echo '<input type="hidden" name="branche" value="'.$_POST['branche'].'">';
    //echo $_POST['size'];
    //echo $_POST['branche'];
    }`


    That function.php is saving data from an questionaire which is containing values.
    My problem is as easy as complex. I am moving through this questionaire through an javascript:






    function senden(goBack){

    if(goBack==0)
    {
    document.getElementById('page').value++;
    if( document.getElementById('page').value >9){
    document.getElementById('submitForm').action='auswertung.php';

    }
    document.getElementById('submitForm').submit();
    }
    else
    {
    document.getElementById('page').value--;
    if( document.getElementById('page').value <1){
    document.getElementById('submitForm').action='branche.php';

    }
    document.getElementById('submitForm').submit();
    }

    }





    And of course some html for the buttons:






      <input type="hidden" id="page" name="page" value="<?php echo $page; ?>" />
    <button type="button" id="doubleButtons" class="btn btn-default" onclick="senden(1)">Zurück</button>
    <button type="button" id="doubleButtons" class="btn btn-default" onclick="senden(0)"><?php echo $page==9?"FDC Auswerten":"Weiter";?></button>





    The questionnaire got those radio buttons which i am talking about, a button for next and a button for back.



    My problem is : If i am filling my questionnaire and press the back button, the filled stuff is gone!
    So my idea was to save everything into an array, but can you give me a hint how i have to do it?



    I hope my question is quite clear, if not, please excuse me and let me know!










    share|improve this question



























      -1












      -1








      -1







      Good day experts!



      I am stuck on a problem.
      This is my function.php



       function tbl_questions() {
      global $mysqlhost, $mysqluser, $mysqlpwd, $mysqldb;



      $connection=mysqli_connect($mysqlhost, $mysqluser, $mysqlpwd) or die ("Verbindungsversuch fehlgeschlagen");
      mysqli_select_db($connection, $mysqldb) or die("Konnte die Datenbank nicht waehlen.");
      $sql_tbl_questions = "SELECT * FROM `questions` where istAktiv='1'";
      $quest_query = mysqli_query($connection, $sql_tbl_questions) or die("Anfrage nicht erfolgreich");

      $i = 0;

      while ($question = mysqli_fetch_array($quest_query)) {
      $i++;
      echo '<tr>';
      echo '<th>'.$i.'</th>';
      echo '<th>'.$question['question'].'</th>';
      echo '<th class="text-center"><input type="radio" name="'.$question['dimension'].'_question_'.$question['id'].'" value="0" required></th>';
      echo '<th class="text-center"><input type="radio" name="'.$question['dimension'].'_question_'.$question['id'].'" value="2.5"></th>';
      echo '<th class="text-center"><input type="radio" name="'.$question['dimension'].'_question_'.$question['id'].'" value="5"></th>';
      echo '<th class="text-center"><input type="radio" name="'.$question['dimension'].'_question_'.$question['id'].'" value="7.5"></th>';
      echo '<th class="text-center"><input type="radio" name="'.$question['dimension'].'_question_'.$question['id'].'" value="10"></th>';
      echo '</tr>';
      $dimensions = $question['dimension'];
      }
      echo '<tr>';
      echo '<th></th>';
      echo '<th>Kommentar/Ihre Anmerkung</th>';
      echo '<th class="text-center" colspan=5><textarea rows=3 cols=50 name="Kommentar"></textarea></th>';
      echo '</tr>';

      echo '<input type="hidden" name="gesamt" value="'.$i.'">';
      echo '<input type="hidden" name="dimensions" value="'.$dimensions.'">';
      echo '<input type="hidden" name="size" value="'.$_POST['size'].'">';
      echo '<input type="hidden" name="branche" value="'.$_POST['branche'].'">';
      //echo $_POST['size'];
      //echo $_POST['branche'];
      }`


      That function.php is saving data from an questionaire which is containing values.
      My problem is as easy as complex. I am moving through this questionaire through an javascript:






      function senden(goBack){

      if(goBack==0)
      {
      document.getElementById('page').value++;
      if( document.getElementById('page').value >9){
      document.getElementById('submitForm').action='auswertung.php';

      }
      document.getElementById('submitForm').submit();
      }
      else
      {
      document.getElementById('page').value--;
      if( document.getElementById('page').value <1){
      document.getElementById('submitForm').action='branche.php';

      }
      document.getElementById('submitForm').submit();
      }

      }





      And of course some html for the buttons:






        <input type="hidden" id="page" name="page" value="<?php echo $page; ?>" />
      <button type="button" id="doubleButtons" class="btn btn-default" onclick="senden(1)">Zurück</button>
      <button type="button" id="doubleButtons" class="btn btn-default" onclick="senden(0)"><?php echo $page==9?"FDC Auswerten":"Weiter";?></button>





      The questionnaire got those radio buttons which i am talking about, a button for next and a button for back.



      My problem is : If i am filling my questionnaire and press the back button, the filled stuff is gone!
      So my idea was to save everything into an array, but can you give me a hint how i have to do it?



      I hope my question is quite clear, if not, please excuse me and let me know!










      share|improve this question















      Good day experts!



      I am stuck on a problem.
      This is my function.php



       function tbl_questions() {
      global $mysqlhost, $mysqluser, $mysqlpwd, $mysqldb;



      $connection=mysqli_connect($mysqlhost, $mysqluser, $mysqlpwd) or die ("Verbindungsversuch fehlgeschlagen");
      mysqli_select_db($connection, $mysqldb) or die("Konnte die Datenbank nicht waehlen.");
      $sql_tbl_questions = "SELECT * FROM `questions` where istAktiv='1'";
      $quest_query = mysqli_query($connection, $sql_tbl_questions) or die("Anfrage nicht erfolgreich");

      $i = 0;

      while ($question = mysqli_fetch_array($quest_query)) {
      $i++;
      echo '<tr>';
      echo '<th>'.$i.'</th>';
      echo '<th>'.$question['question'].'</th>';
      echo '<th class="text-center"><input type="radio" name="'.$question['dimension'].'_question_'.$question['id'].'" value="0" required></th>';
      echo '<th class="text-center"><input type="radio" name="'.$question['dimension'].'_question_'.$question['id'].'" value="2.5"></th>';
      echo '<th class="text-center"><input type="radio" name="'.$question['dimension'].'_question_'.$question['id'].'" value="5"></th>';
      echo '<th class="text-center"><input type="radio" name="'.$question['dimension'].'_question_'.$question['id'].'" value="7.5"></th>';
      echo '<th class="text-center"><input type="radio" name="'.$question['dimension'].'_question_'.$question['id'].'" value="10"></th>';
      echo '</tr>';
      $dimensions = $question['dimension'];
      }
      echo '<tr>';
      echo '<th></th>';
      echo '<th>Kommentar/Ihre Anmerkung</th>';
      echo '<th class="text-center" colspan=5><textarea rows=3 cols=50 name="Kommentar"></textarea></th>';
      echo '</tr>';

      echo '<input type="hidden" name="gesamt" value="'.$i.'">';
      echo '<input type="hidden" name="dimensions" value="'.$dimensions.'">';
      echo '<input type="hidden" name="size" value="'.$_POST['size'].'">';
      echo '<input type="hidden" name="branche" value="'.$_POST['branche'].'">';
      //echo $_POST['size'];
      //echo $_POST['branche'];
      }`


      That function.php is saving data from an questionaire which is containing values.
      My problem is as easy as complex. I am moving through this questionaire through an javascript:






      function senden(goBack){

      if(goBack==0)
      {
      document.getElementById('page').value++;
      if( document.getElementById('page').value >9){
      document.getElementById('submitForm').action='auswertung.php';

      }
      document.getElementById('submitForm').submit();
      }
      else
      {
      document.getElementById('page').value--;
      if( document.getElementById('page').value <1){
      document.getElementById('submitForm').action='branche.php';

      }
      document.getElementById('submitForm').submit();
      }

      }





      And of course some html for the buttons:






        <input type="hidden" id="page" name="page" value="<?php echo $page; ?>" />
      <button type="button" id="doubleButtons" class="btn btn-default" onclick="senden(1)">Zurück</button>
      <button type="button" id="doubleButtons" class="btn btn-default" onclick="senden(0)"><?php echo $page==9?"FDC Auswerten":"Weiter";?></button>





      The questionnaire got those radio buttons which i am talking about, a button for next and a button for back.



      My problem is : If i am filling my questionnaire and press the back button, the filled stuff is gone!
      So my idea was to save everything into an array, but can you give me a hint how i have to do it?



      I hope my question is quite clear, if not, please excuse me and let me know!






      function senden(goBack){

      if(goBack==0)
      {
      document.getElementById('page').value++;
      if( document.getElementById('page').value >9){
      document.getElementById('submitForm').action='auswertung.php';

      }
      document.getElementById('submitForm').submit();
      }
      else
      {
      document.getElementById('page').value--;
      if( document.getElementById('page').value <1){
      document.getElementById('submitForm').action='branche.php';

      }
      document.getElementById('submitForm').submit();
      }

      }





      function senden(goBack){

      if(goBack==0)
      {
      document.getElementById('page').value++;
      if( document.getElementById('page').value >9){
      document.getElementById('submitForm').action='auswertung.php';

      }
      document.getElementById('submitForm').submit();
      }
      else
      {
      document.getElementById('page').value--;
      if( document.getElementById('page').value <1){
      document.getElementById('submitForm').action='branche.php';

      }
      document.getElementById('submitForm').submit();
      }

      }





        <input type="hidden" id="page" name="page" value="<?php echo $page; ?>" />
      <button type="button" id="doubleButtons" class="btn btn-default" onclick="senden(1)">Zurück</button>
      <button type="button" id="doubleButtons" class="btn btn-default" onclick="senden(0)"><?php echo $page==9?"FDC Auswerten":"Weiter";?></button>





        <input type="hidden" id="page" name="page" value="<?php echo $page; ?>" />
      <button type="button" id="doubleButtons" class="btn btn-default" onclick="senden(1)">Zurück</button>
      <button type="button" id="doubleButtons" class="btn btn-default" onclick="senden(0)"><?php echo $page==9?"FDC Auswerten":"Weiter";?></button>






      javascript php html






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 12 '18 at 10:04









      cmprogram

      1,103519




      1,103519










      asked Nov 12 '18 at 9:53









      Arti

      14




      14
























          1 Answer
          1






          active

          oldest

          votes


















          0














          try using history.back function?



          <button onclick="history.back()">Back</button>





          share|improve this answer





















          • but how do i save my values ( which are stored from the radio buttons) ?
            – Arti
            Nov 12 '18 at 10:03










          • store or retrieve it from form? your problem is you want to get the values from form when you press back button am I right? you can obtain their values if you save them in array, you can refer to this post, hope it helps :D stackoverflow.com/questions/2619163/…
            – ha_ryu
            Nov 12 '18 at 10:09












          • i need to store each questions value from the radio button. So the user can click on back, and the radio buttons values are retrieved. so i need both, thats the hard part about it which i dont get :/
            – Arti
            Nov 12 '18 at 10:18











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53259609%2fhow-do-i-fill-an-php-array-with-my-session-and-other-variablesjs%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          try using history.back function?



          <button onclick="history.back()">Back</button>





          share|improve this answer





















          • but how do i save my values ( which are stored from the radio buttons) ?
            – Arti
            Nov 12 '18 at 10:03










          • store or retrieve it from form? your problem is you want to get the values from form when you press back button am I right? you can obtain their values if you save them in array, you can refer to this post, hope it helps :D stackoverflow.com/questions/2619163/…
            – ha_ryu
            Nov 12 '18 at 10:09












          • i need to store each questions value from the radio button. So the user can click on back, and the radio buttons values are retrieved. so i need both, thats the hard part about it which i dont get :/
            – Arti
            Nov 12 '18 at 10:18
















          0














          try using history.back function?



          <button onclick="history.back()">Back</button>





          share|improve this answer





















          • but how do i save my values ( which are stored from the radio buttons) ?
            – Arti
            Nov 12 '18 at 10:03










          • store or retrieve it from form? your problem is you want to get the values from form when you press back button am I right? you can obtain their values if you save them in array, you can refer to this post, hope it helps :D stackoverflow.com/questions/2619163/…
            – ha_ryu
            Nov 12 '18 at 10:09












          • i need to store each questions value from the radio button. So the user can click on back, and the radio buttons values are retrieved. so i need both, thats the hard part about it which i dont get :/
            – Arti
            Nov 12 '18 at 10:18














          0












          0








          0






          try using history.back function?



          <button onclick="history.back()">Back</button>





          share|improve this answer












          try using history.back function?



          <button onclick="history.back()">Back</button>






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 12 '18 at 9:59









          ha_ryu

          416413




          416413












          • but how do i save my values ( which are stored from the radio buttons) ?
            – Arti
            Nov 12 '18 at 10:03










          • store or retrieve it from form? your problem is you want to get the values from form when you press back button am I right? you can obtain their values if you save them in array, you can refer to this post, hope it helps :D stackoverflow.com/questions/2619163/…
            – ha_ryu
            Nov 12 '18 at 10:09












          • i need to store each questions value from the radio button. So the user can click on back, and the radio buttons values are retrieved. so i need both, thats the hard part about it which i dont get :/
            – Arti
            Nov 12 '18 at 10:18


















          • but how do i save my values ( which are stored from the radio buttons) ?
            – Arti
            Nov 12 '18 at 10:03










          • store or retrieve it from form? your problem is you want to get the values from form when you press back button am I right? you can obtain their values if you save them in array, you can refer to this post, hope it helps :D stackoverflow.com/questions/2619163/…
            – ha_ryu
            Nov 12 '18 at 10:09












          • i need to store each questions value from the radio button. So the user can click on back, and the radio buttons values are retrieved. so i need both, thats the hard part about it which i dont get :/
            – Arti
            Nov 12 '18 at 10:18
















          but how do i save my values ( which are stored from the radio buttons) ?
          – Arti
          Nov 12 '18 at 10:03




          but how do i save my values ( which are stored from the radio buttons) ?
          – Arti
          Nov 12 '18 at 10:03












          store or retrieve it from form? your problem is you want to get the values from form when you press back button am I right? you can obtain their values if you save them in array, you can refer to this post, hope it helps :D stackoverflow.com/questions/2619163/…
          – ha_ryu
          Nov 12 '18 at 10:09






          store or retrieve it from form? your problem is you want to get the values from form when you press back button am I right? you can obtain their values if you save them in array, you can refer to this post, hope it helps :D stackoverflow.com/questions/2619163/…
          – ha_ryu
          Nov 12 '18 at 10:09














          i need to store each questions value from the radio button. So the user can click on back, and the radio buttons values are retrieved. so i need both, thats the hard part about it which i dont get :/
          – Arti
          Nov 12 '18 at 10:18




          i need to store each questions value from the radio button. So the user can click on back, and the radio buttons values are retrieved. so i need both, thats the hard part about it which i dont get :/
          – Arti
          Nov 12 '18 at 10:18


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53259609%2fhow-do-i-fill-an-php-array-with-my-session-and-other-variablesjs%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          這個網誌中的熱門文章

          Xamarin.form Move up view when keyboard appear

          Post-Redirect-Get with Spring WebFlux and Thymeleaf

          Anylogic : not able to use stopDelay()