By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,009 Members | 2,859 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,009 IT Pros & Developers. It's quick & easy.

Using multiple buttons with PHP

P: 2
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:

Expand|Select|Wrap|Line Numbers
  1. <h1>Music Quiz</h1>
  2.   <form action = "exam1.php" method = "post">
  3.     <p>
  4.       Which of the following composers were NOT famous during the
  5.       Renaissance period (1600-1750)? <br />
  6.       <select name = "questionOne">
  7.         <option></option>
  8.         <option value = "Guillaume Dufay">Guillaume Dufay</option>
  9.         <option value = "Josquin des Prez">Josquin des Prez</option>
  10.         <option value = "Henry Purcell">Henry Purcell</option>
  11.         <option value = "Palestrina">Palestrina</option>
  12.       </select>
  13.     </p>
  14.     <p>
  15.           <input type ="button" value="Previous Question" />
  16.       <input type = "submit" value = "Save" />
  17.           <input type = "submit" value = "Submit" />
  18.           <input type = "button" value = "Next Question" />
  19.     </p>
  20.   </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.
Oct 13 '09 #1
Share this Question
Share on Google+
3 Replies

code green
Expert 100+
P: 1,726
Give them different names
Oct 13 '09 #2

P: 2
How do you refer to the names in the PHP code? How can I make the PHP handle next and previous? Any ideas?
Oct 13 '09 #3

Expert Mod 5K+
P: 8,639
Expand|Select|Wrap|Line Numbers
  1. $_POST['name']
save somewhere the sequence of the files and walk through that. (there are too many possibilities to list them all)
Oct 13 '09 #4

Post your reply

Sign in to post your reply or Sign up for a free account.