I am currently working in PHP I am new to development in PHP and I am having quite a time trying to get a form to submit then update a value each time it is submitted.
So here is the gist of it. I am submitting my form to self at which time it runs this:
<div id="quiz">
<form method="post" id="test" action="">
<input type="hidden" value="<?php $question->set_results() ?>">
Answer A<input type="radio" name="answer" value="a">
Answer B<input type="radio" name="answer" value="b">
Answer C<input type="radio" name="answer" value="c">
Answer D<input type="radio" name="answer" value="d">
<input type="submit">
</form>
class test_results{
public function get_results(){
$this->lastanswer = array();
$this->personsanswer = $_POST['answer'];
$this->allanswers = array_push($this->lastanswer, $this->personsanswer);
implode($this->lastanswer);
echo $this->allanswers;
}
}
After this runs it seems to work but instead of updating the variable it just adds a number where I wanted it to update. All in all I just want to be able to submit a form, after submitting a form I have a hidden field in the form and I want it to update that hidden field with the ALL of the previous options chosen. I have gotten it as far as to update one option at a time but not multiple times.
My end goal is to have a questionnaire form where users fill out answers one question at a time and each time they submit the form the hidden field holds ALL of the previous answer letters in it.