1

I am learning PHP and have a situation where I want the method to be POST to pass variables to my php and

1) Connect to Server
2) store results in a variable
3) Display an HTML Table

However, I later on in my syntax want to use GET to "recall" that variable and output the results to a CSV file. This is what I have, but when I click the button Generate nothing happens. Is this possible? If not, how should I re-write the syntax to make ithappen?

<body>
    <form method="POST">
        End Date:<input type="date" name="end" value="<?= $_POST['end'] ?>">
        <input type="submit" name="submit" value="Go">
    </form>
</body>
<?php
   if (isset($_POST['submit'])) 
   {
       //Connect To Server
       //Store Result Set in Variable
       //Display HTML Table
   }
?>

<form method="get">
    <button type="submit" name="csv" value="1">Generate CSV</button>
</form>
RAUSHAN KUMAR
  • 5,846
  • 4
  • 34
  • 70
Hot Love
  • 27
  • 4
  • you don't need 2 forms. You can pass a GET argument in the action, or use sessions. – Funk Forty Niner Jun 27 '17 at 13:28
  • @Fred-ii- - how would I pass a get and set? – Hot Love Jun 27 '17 at 13:29
  • something like https://stackoverflow.com/questions/10977874/is-there-a-way-to-use-get-and-post-together --- https://stackoverflow.com/questions/2036858/want-to-use-both-get-and-post-methods --- https://stackoverflow.com/questions/2749406/post-and-get-at-the-same-time-in-php – Funk Forty Niner Jun 27 '17 at 13:33
  • Looking at the second link you posted. `
    ` - I do not have an external php file, my php markup is all in the same file. Would I just use the current page name then?
    – Hot Love Jun 27 '17 at 13:45
  • yes you could use the same file. Something like `action="?var1...."` etc. should work. – Funk Forty Niner Jun 27 '17 at 13:47

0 Answers0