-1

I have "upload.php" page which consists of upload form and radio button form.

<html lang="en">
<form action="upload.php" method="post" enctype="multipart/form-data">
<label for="my_upload">1) Select a file to upload:</label>
<input id="my_upload" name="my_upload" type="file">
<input type="submit" value="Upload">
</form>

<form action="./execute.php">
<input type="hidden" name="parameter"  value=" ? ">
<input type="radio" name="mode" value="one">one<br>
<input type="radio" name="mode" value="two">two<br> 
<input type="submit" value="Execute">
</html>

<?php
... php upload code ...
$parameter;

When I select file to upload and press button "Upload", php code on the same page "upload.php" starts running. After it finishes, I would like to take value "$parameter" and use it in html code on the same page, in next form with radio buttons. Is there a way to do this? Also, is there a way to get values/variables from "execute.php" after it is actually executed and use them on page "upload.php"?

7
  • 3
    Have you read this documentation on file uploading on the PHP website? php.net/manual/en/features.file-upload.post-method.php Commented Nov 9, 2019 at 21:20
  • It is just an example, I am interested in variables/parameters, not in the actual upload itself. :) Thanks! Commented Nov 9, 2019 at 21:22
  • No, sorry, it does not. The actual function of upload is not important in my question. Commented Nov 9, 2019 at 21:26
  • Didn't you ask something like this earlier? Commented Nov 9, 2019 at 21:31
  • @FunkFortyNiner No, I asked there about passing parameters in URL between different PHP pages. I am now interested in using/passing parameters between PHP and HTML on the same page. Thanks! Commented Nov 9, 2019 at 21:33

1 Answer 1

1

Just place your php code above your html stuff:

<?php
... php upload code ...
$parameter;
?>

<html lang="en">
<form action="upload.php" method="post" enctype="multipart/form-data">
<label for="my_upload">1) Select a file to upload:</label>
<input id="my_upload" name="my_upload" type="file">
<input type="submit" value="Upload">
</form>

<form action="./execute.php">
<input type="hidden" name="parameter"  value="<?php echo $parameter ?>">
<input type="radio" name="mode" value="one">one<br>
<input type="radio" name="mode" value="two">two<br> 
<input type="submit" value="Execute">
</form>
</html>

And close the second form with /form.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.