woodplease Posted February 2, 2010 Share Posted February 2, 2010 i have a form where i post values, and then retrieve them on another page, but only one of the values is being retrieved. This is my post form <?php $id = $_GET['id']; $query = "SELECT * FROM questions WHERE quizref = " .$id ; $question = 'questionno'; $result2 = pg_query($query) or die ("Query failed"); //let's get the number of rows in our result so we can use it in a for loop $numofrows = pg_num_rows($result2); ?> <form method="post" action ="editquestions.php"> <?PHP for($i = 1; $i <= $numofrows; $i++) { $row = pg_fetch_array($result2); //get a row from our result set echo '<input type="hidden" name="quizno" value="'.$id.'"> <input type="hidden" name="questionno" id="'.$row['questionno'].'" value="'.$row['questionno'].'" > <br/><p>Question '.$row['questionno'].': ' .$row['question'].' <input type="Submit" id="'.$row['questionno'].'" value="EDIT"> <br/><br/></p> and this is the code that retrieves it $id = $_POST['quizno']; $question = $_POST['questionno']; echo 'The quiz number is:'.$id; echo'<br/>The question number is:'.$question; It is only displaying the $id correctly,and it displays the $question as the total number of questions on the previous page, even though when you view the source, the value that is to be sent is thequestion number. this is the link to the page that originally posts the information, and then when you click the edit button, it takes you to the page that is supposed to display that information http://users.aber.ac.uk/agd8/quizdom/questionlist.php?id=1 Quote Link to comment https://forums.phpfreaks.com/topic/190665-value-not-being-posted-to-next-page/ Share on other sites More sharing options...
MatthewJ Posted February 2, 2010 Share Posted February 2, 2010 Not sure if it will help, but you should properly close your form tags... Hidden elements should end with /> as they are self closing tags Quote Link to comment https://forums.phpfreaks.com/topic/190665-value-not-being-posted-to-next-page/#findComment-1005528 Share on other sites More sharing options...
KevinM1 Posted February 2, 2010 Share Posted February 2, 2010 You have multiple hidden inputs with the same name but different values. PHP is getting the result of the last one. Change up the names. Quote Link to comment https://forums.phpfreaks.com/topic/190665-value-not-being-posted-to-next-page/#findComment-1005534 Share on other sites More sharing options...
proud Posted February 2, 2010 Share Posted February 2, 2010 Just check the tags Quote Link to comment https://forums.phpfreaks.com/topic/190665-value-not-being-posted-to-next-page/#findComment-1005535 Share on other sites More sharing options...
woodplease Posted February 2, 2010 Author Share Posted February 2, 2010 i've fixed it now, i've decide to send the question number in the url instead Quote Link to comment https://forums.phpfreaks.com/topic/190665-value-not-being-posted-to-next-page/#findComment-1005556 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.