x_maras Posted April 21, 2009 Share Posted April 21, 2009 Hi, I'm writing a questionnaire and I ve got different questions in different pages. For changing pages I use this. $nextpage = $currentpage + 1; echo "<a href='questionnaire.php?currentpage=". $nextpage ."' class='next'> <input type='submit' name='nextbutton' value='next >>' /> </a>"; I thought to make the link to the next page a submit button in order to submit the form also and to save the values in an array and then the array in a session. The questions are being loaded from a database so there is not specific number of questions or question types in every page. The thing is that when I press the button next I can't even do this: if(isset($_POST['nextbutton'])){ echo "something"; } and here is a bigger part of the code: if($currentpage <= $arraycheck){ //selects one record from the specific position $sqlPresentCategories = "SELECT * FROM categories WHERE enquete_id=". $enquete ." LIMIT ". $arrayPosition[$currentpage] .", 1"; $resultPresentCategories = mysql_query($sqlPresentCategories); while($categoryShow = mysql_fetch_array($resultPresentCategories)){ echo $categoryShow['category'] ."<br />"; $questionNumber = 1;//used for numering the questions as they are presented in the page $sqlQuestions = "SELECT * FROM questions WHERE cat_id=". $categoryShow['id'] ." AND visibility='on'"; $resQuestions = mysql_query($sqlQuestions); echo " <form method='POST'>"; //fetching the questions which have the visibility turned on while($questionCheck = mysql_fetch_array($resQuestions)){ $paramQuestionId = $questionCheck['id']; $paramQuestionText = $questionCheck['text']; $switchVar = $questionCheck['type_id']; //3 types of questions and 3 types of checks switch($switchVar){ case 1: normalQuestions($paramQuestionId, $questionNumber); break; case 2: radioImagesQuestions($paramQuestionId, $paramQuestionText, $questionNumber); break; case 3: checkboxQuestions($paramQuestionId, $paramQuestionText, $questionNumber); break; default: echo "Error! All the questions should have a type"; } $questionNumber++; } if($currentpage <= $arraycheck){ // get next page $nextpage = $currentpage + 1; // echo forward link for next page echo "<a href='questionnaire.php?currentpage=". $nextpage ."' class='next'> <input type='submit' name='nextbutton' value='next >>' /> </a>"; } echo " </form>"; if(isset($_POST['nextbutton'])){ echo "something"; } } } Sorry for the big post and I thank in advance everyone who at least try to read this post. Link to comment https://forums.phpfreaks.com/topic/155018-pagination-and-forms-submit/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.