I currently have two html forms. They both POST to process.php: one posts text entered into a textarea, the other posts an uploaded file. The value of a hidden input called 'act' is either 'paste' or 'upload' respectively, and this is used by process.php to distinguish the two forms. The current code (below) works fine.
<!--Box to paste list of queries-->
<form enctype="multipart/form-data" action="process.php" method="POST" onSubmit="return showPleaseWait()">
<?php //This hidden input value 'paste' is used by process.php to distinguish the two forms ?>
<input type="hidden" name="act" value="paste"/>
<b><font color="#1F88A7">Paste in a list (one query per line):<br/></b><br/>
<textarea id="text" cols="15" rows="6" name="ID_list" style='background-color:#ffffff; border:solid 1px #1F88A7'></textarea>
<input id="butt" name="sub" type="submit" value="Submit" /><br />
</form>
<br />
<!--Box to upload a file -->
<form enctype="multipart/form-data" action="process.php" method="POST" onSubmit="return showPleaseWait()">
<?php //This hidden input value 'upload' is used by process.php to distinguish the two forms ?>
<input type="hidden" name="act" value="upload"/>
<b><font color="#1F88A7">Or upload (plain text, one query per line):</font> </b><br />
<input id="butt" name="uploadedfile" type="file" style='background-color:#ffffff; border:solid 1px #1F88A7'/><input type="submit" value="Upload File" />
</form>
In process.php I have this:
if (isset($_POST['act'])){
if ($_POST['act'] == 'upload'){
// ...process one way
echo "file uploaded";
}else if($_POST['act'] == 'paste'){
// ...process another way
echo "text uploaded";
}
}
What I would like to do now is to add a single dropdown menu that will post with whichever of these two forms are submitted. I can paste the code below into both of the two forms, but then I have this dropdown menu displayed twice (once for each form). I would like to display this dropdown menu only once at the top of the page, and its value to be posted with whichever of the two forms ('paste' or 'upload') is submitted.
<form action="process.php" method="post">
<b><font color="#1F88A7">Select your query type:</font> </b><br />
<select name="ID_type">
<option value=""></option>
<option value="type1">type1</option>
<option value="type2">type2</option>
<option value="type3">type3</option>
</option>
</select>
</form>
The goal is to process different types of query differently by including if statements into process.php, such as:
if ($_POST['ID_type'] == 'type1'){}
The problem seems simple, and maybe I can't solve it because of my lack of familiarity with html (apologies if there is anything horrible in the html above), but I have not been able to find a solution. Many many thanks for any help.