PHP setting session variables on button click
<p>When a user click either 4/6 'Snacks Per Shipment', and weekly/fortnightly/monthly 'Shipment Frequency', a function displays the details on the right hand side above the button.</p>

<p>I'm a noob developer looking to store whatever information a user chooses, as a session variable once the button 'Choose your snacks' is clicked. In this example, I would be looking to store 4 and fortnightly.</p>

<p><a href="https://i.stack.imgur.com/mynIP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mynIP.png" alt="enter image description here"></a></p>

<p>Here is my PHP code when starting the session</p>

<pre><code>&lt;?php
session_start();

include_once 'dbconnect.php';

if(isset($_POST['choose']))
{

$unit = document.getElementById('unit').innerHTML;
$frequency = document.getElementById('frequency').innerHTML;


// Set session variables
$_SESSION["unit"] = $unit;
$_SESSION["frequency"] = $frequency;

}

?&gt;
</code></pre>

<p>Here is the code related to the button</p>

<pre><code>&lt;div class="pricing-button" method="POST"&gt;
&lt;a href="session.php" class="btn btn-yellow btn-rounded btn-lg"
name="choose" type="submit"&gt;Choose Your Snacks&lt;/a&gt;
&lt;/div&gt;
</code></pre>

<p>Here is my code related to scraping what the user chooses</p>

<pre><code>&lt;script&gt;
function change(unit){
document.getElementById('unit').innerHTML = unit;
}

function frequency(frequency){
document.getElementById('frequency').innerHTML = frequency;
}
&lt;/script&gt;
</code></pre>

<p>And here's where i'm testing if the session variables are working or not</p>

<pre><code> &lt;?php
 session_start();
 ?&gt;
&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;body&gt;

 &lt;?php
// Echo session variables that were set on previous page
echo "Customer wants " . $_SESSION["unit"] . "&lt;br&gt;";
echo "This many times " . $_SESSION["frequency"] . "&lt;br&gt;";
?&gt;
</code></pre>

<p>
</p>