Using multiple buttons with PHP

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • brian210
    New Member
    • Oct 2009
    • 2

    Using multiple buttons with PHP

    I am currently trying to make a four question quiz. Each question is on a new page. There will be a previous button and a next button to take the user to the previous and next question respectively. There will also be a save button to save the current answer selected for the questions so far. Finally, I will have a submit button that will submit all the answers of the quiz and give back a score. I have to use these buttons, and I have to have my page setup in this way. However, I am not sure how I should handle the buttons.

    I currently have my HTML file as such which will send to a php file:

    Code:
    <h1>Music Quiz</h1>
      <form action = "exam1.php" method = "post">
        <p>
          Which of the following composers were NOT famous during the
    	  Renaissance period (1600-1750)? <br />
    	  <select name = "questionOne">
    	    <option></option>
    	    <option value = "Guillaume Dufay">Guillaume Dufay</option>
    	    <option value = "Josquin des Prez">Josquin des Prez</option>
    	    <option value = "Henry Purcell">Henry Purcell</option>
    	    <option value = "Palestrina">Palestrina</option>
    	  </select>
    	</p>
    	<p>
              <input type ="button" value="Previous Question" />
    	  <input type = "submit" value = "Save" />
              <input type = "submit" value = "Submit" />
              <input type = "button" value = "Next Question" />
    	</p>
      </form>
    The PHP file can print the next question if the next question button was selected, etc. I should be able to handle everything in the php file. However, I don't know how to determine which buttons were pressed in my php file. How should I handle the next and previous buttons? How do I know which submit button was selected? Any help will be greatly appreciated.
    Last edited by Dormilich; Oct 13 '09, 07:46 PM. Reason: Please use [code] tags when posting code
  • code green
    Recognized Expert Top Contributor
    • Mar 2007
    • 1726

    #2
    Give them different names

    Comment

    • brian210
      New Member
      • Oct 2009
      • 2

      #3
      How do you refer to the names in the PHP code? How can I make the PHP handle next and previous? Any ideas?

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        Originally posted by brian210
        How do you refer to the names in the PHP code?
        Code:
        $_POST['name']
        Originally posted by brian210
        How can I make the PHP handle next and previous? Any ideas?
        save somewhere the sequence of the files and walk through that. (there are too many possibilities to list them all)

        Comment

        Working...