I have an index page that upload a file. An input button does the upload of the file and another import the grades to an external system. To import the grades, the user should be authenticated. Because of this, I have create two forms, and each button is in a form. However, it is not working because the first time that upload a grade and click import grades, it works just fine. The second time, when I click on "Upload file" button, it does the import grade at the same time. How I do to separate this actions, or better, add those two action in a same button?
I already tried to merge both forms by adding action="authenticateUser.php"
to the first form
and remove the second form
, but it doesn't work.
<title>Import Grades Widget</title>
<form action="" method="POST" enctype="multipart/form-data">
<labeL class="tool-actions"> <span>Choose CSV File:</span></labeL>
<input class="tool-actions" type="file" accept="text/csv" id='uploadfile' name="userfile" />
<p>
<!--add space btw buttons -->
<br>
<input class="btn-primary" type="submit" name="send" id="btnSend" value="Upload file" />
<labeL class="tool-actions"> <span></span></labeL>
<?php
require_once "upload.php";
?>
<p id="info-message-crn" style="color:red"></p>
</form>
<form method="POST" enctype="multipart/form-data" action="authenticateUser.php" id="configForm">
<input class="btn-primary" type="submit" id="btnImport" name="btnImport" value="Import Grades" />
<?php
if(file_exists("uploads/uploadFile.csv") AND isset($_POST['btnImport'])) {
require_once ('apiCalls.php');
}else {
?>
<p style="color:grey" id="info-message">
<?php echo "Select a csv file.";?>
</p>
<?php
}
?>
</form>