I have a form which consists of a dropdown and when the user submits the Information, it gets submitted to a PHP Page. Now based on the Response the user has selected on the dropdown, I created another form and I am trying to submit the Information. My Question is, Is it possible to have a post method within a php file?
HTML
<form method="post" name="project_form" action="php/harvest_clientproject.php">
Client Name:
<select id="clt" name="client_name">
<option value="A">Client A</option>
<option value="B">Client B</option>
<input type="submit" value="Submit">
</form>
PHP File 1-Clientproject.php
$client_id_dropdown=$_POST['client_name'];
echo $client_id_dropdown;
/*Convert String to Integer */
$client_id_dropdown_int=(int) $client_id_dropdown;
/*Populating a dropdown with the list of projects from an array $data*/
echo " <form method= "post" name="project_form_2" action="harvest_clientproject2.php">
<select id="animal" name="project_name">";
// Iterating through the product array
foreach($data as $ $key=>$fruit){
echo "<option value= "; echo $fruit->{'id'}; echo ">" ;echo $fruit->{'name'};echo"</option>";
}
?> echo "
</select>
<input type="submit" value="Submit">
</form>";
PHP File 2-harvest_clientproject2.php
*Getting Project ID */
$projectid=$_POST['project_name'];
/*Convert String to Integer */
$projectid_int=(int) $projectid;
/*Generating Project Details and putting it in the form of a table */
$result = $api->getProject($projectid);
$data = $result->get( "data" );
echo "<table border='1'>
<tr><td>Project Name</td>
<td>Project Creation Date</td>
<td>Billable</td>
</tr>";
foreach($data as $key=>$fruit) {
?>
<tr><td><?php echo $fruit->name;?></td>
<td><?php echo $fruit->{'created-at'};?></td>
<td><?php echo $fruit->{'billable'};?></td></tr>
<?php ;}
echo "</table>";
?>
But once I try to do this it gives an error in the First PHP File saying "Syntax Error Unexpected Post". Kindly suggest on how could I overcome this Issue