Note that there are some explanatory texts on larger screens.

plurals
  1. POPhp Submit Form Action
    primarykey
    data
    text
    <p>I have a function that creates a URL depending on what product and what quantity the customer selected from the form page.</p> <p>The function looks something like this:</p> <pre><code>function getPurchaseLink($token, $csvfile, $force_platform = "", $quantity = 1){ // Code to create url } </code></pre> <p>Each product has its own form with a <strong>select dropdown</strong> list of quantity.</p> <p>The problem is when I hard code it the quantity like: <strong>$quantity = 1;</strong> and in the form action I put: </p> <pre><code>&lt;form method="post" action="&lt;?php echo getPurchaseLink($TOKEN, $csvfile, $force_platform = "", $quantity); ?&gt;"&gt; </code></pre> <p>It works when I submit the form.</p> <p>But it's not the way I want it. I want to get the quantity value of the select box options. Like <strong>$quantity = $_POST['quantity'];</strong></p> <p>But I got an Undefined Error, When the page is load. So, I can't submit the form if I can't get the quantity value from the select box.</p> <p>Here's my whole form:</p> <pre><code>&lt;?php require 'script_purchase.php'; $csvfile = 'purchaselinks.csv'; //echo getPurchaseLink($token = '1Opp2p11M', $csvfile, $force_platform = "", $quantity = 99) . '&lt;br/&gt;'; $quantity = $_POST['quantity']; ?&gt; &lt;html&gt; &lt;body&gt; &lt;form method="post" action="&lt;?php echo getPurchaseLink('1Opp2p11M', $csvfile, $force_platform = "", $quantity); ?&gt;"&gt; &lt;div class="comp"&gt; &lt;label class="font_12" for="quantity"&gt;# of PCs&lt;/label&gt;&lt;br/&gt; &lt;select class="font_12" id="quantity" name="quantity"&gt; &lt;option value="10"&gt;10 PCs&lt;/option&gt; &lt;option value="25"&gt;25 PCs&lt;/option&gt; &lt;option value="50"&gt;50 PCs&lt;/option&gt; &lt;option value="99"&gt;99 PCs&lt;/option&gt; &lt;/select&gt; &lt;/div&gt; &lt;div class="div_small"&gt;&lt;span class="font_12"&gt;&lt;br/&gt;for&lt;/span&gt;&lt;/div&gt; &lt;input name="submit" id="button_addtocart" type="submit" value="Submit" class="checkout" /&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload