I'm taking this class and we've just started to learn PHP so I am really new to the subject. I have done some coding and have been emailing my instructor (he has not responded yet) so please do not just click the back button thinking all I want is the answer.
Here is what I need to accomplish: Create a "self-processing" PHP page that will initially just display a simple form with a drop-down select box that lets the user choose between the feedback and help request forms. When the user makes a selection, instead of using JavaScript to dynamically build or reveal the appropriate submission form, the form will be submitted back to the same page on the server for further processing. The PHP page will use a PHP script to check if the user has submitted a choice, and if so it will dynamically display the appropriate form.
This is what my assignment looks like so far: http://www2.esc.edu/jvooris/assignment5-2.php
As you can see, the forms are already displayed even without selecting an option from the drop down menu. What I need to have happen is have that drop down menu appear and then have the appropriate form display after the user clicks the submit button.
So if the user clicks the submit button when the option is still on "Please select the form you want to fill out" then nothing should be displayed. However, if the user clicks the submit button when they select the option "Feedback Form" then that form will appear on the page and the same goes for the "Help Form".
When I emailed my instructor he said that I need to: "Create a PHP page with a form with a drop down menu and a submit button that has a action to post to itself" and "Add PHP code at the top using the isset method to test to see if the page was submitted to itself and if your drop down menu variable was sent."
Like I said, I do have some code already written. My problem is trying to figure out how to make it work correctly and I can't tell if I am way off base with the code I already have or if I just need to tweak a few things. I would appreciate any help in this matter and I hope I did not do too much explaining to deter anyone. Thank you. I will post my code below (I have cut out the code for the forms to shorten the code).
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> <title>PHP Form</title> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <link rel="stylesheet" href="styles.css" type="text/css" /> <!--This links the entire page to the CSS style sheet. The font sizes, colors, colors on the page, etc. are all created on the attached style sheet--> </head> <body> <div id="wrapper"> <!--This statement makes the entire page align to a specific setting as set in the CSS.--> <!--This code first appears on the page to allow the user to select an option--> <form action="assignment5-2.php" name="select"> <p><select name="formChoice" size="1"> <option value="0">Please select the form you want to fill out</option> <?php $formChoice=$_GET["formChoice"]; echo $formChoice; if($formChoice==1)echo "<option value=1 selected='selected'>Feedback Form</option>"; else echo "<option value=1>Feedback Form</option>"; if($formChoice==2)echo "<option value=2> selected='selected'>Help Form</option>"; else echo "<option value=2>Help Form</option>"; ?> <input type="submit" value="Submit"/> </select> </form> <form id="feedbackForm" action="assignment5-2.php" method="GET"> <h1>User Feedback</h1>