Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Nov 2009
    Posts
    16
    Thanks
    2
    Thanked 0 Times in 0 Posts

    value not being POSTED to next page

    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 Code:
    <?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
    PHP Code:
    $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...nlist.php?id=1

  • #2
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    I've just viewed your source, you've only got one opening form tag in there with many input that have duplicate names. so you'll never get the correct result with this setup.

    try adding one form for each block/question.

    PHP Code:
    <?PHP 
    for($i 1$i <= $numofrows$i++) { 
        echo 
    "<form method='post' action ='editquestions.php'>";
        
    $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>
        echo "
    </form>";
    }
    Last edited by angst; 02-02-2010 at 07:41 PM.

  • #3
    Senior Coder
    Join Date
    May 2005
    Posts
    2,137
    Thanks
    96
    Thanked 72 Times in 72 Posts
    When you use a forum, the POST is only given to the next page. You can use SESSION to keep the variable through multiple pages and unset or destory the sessions at the last page.
    Rowsdower! has accused me of having mental problems, and the administrator allowed it. What a great forum huh?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •