I am writing a form, and I may be overcomplicating this, but I want the form to change based on the response to a question. It is a contact form. I want to ask a question, then use a php if else statement to generate the response do if a show this haml, elseif b show this. In the end the form will be emailed to me. Here is my question. If i set the variables in the head section like this:
<?php
$letter = $_POST['letter'];
?>
</html>
<body>
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
<select name="letter'>
<option value="a">a</option>
<option value="b">b</option>
</form>
<?php
if ($letter == a) {html}
elseif ($letter == b) {html}
?>
Would that work, or does the form need to be submited before the variable can be assigned? If it needs to be submited, can that be done as soon as the selection is made in the select tag and how would I do that without the user clicking a submit button?