I have a function that creates a URL depending on what product and what quantity the customer selected from the form page.
The function looks something like this:
function getPurchaseLink($token, $csvfile, $force_platform = "", $quantity = 1){ // Code to create url } Each product has its own form with a select dropdown list of quantity.
The problem is when I hard code it the quantity like: $quantity = 1; and in the form action I put:
<form method="post" action="<?php echo getPurchaseLink($TOKEN, $csvfile, $force_platform = "", $quantity); ?>"> It works when I submit the form.
But it's not the way I want it. I want to get the quantity value of the select box options. Like $quantity = $_POST['quantity'];
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.
Here's my whole form:
<?php require 'script_purchase.php'; $csvfile = 'purchaselinks.csv'; //echo getPurchaseLink($token = '1Opp2p11M', $csvfile, $force_platform = "", $quantity = 99) . '<br/>'; $quantity = $_POST['quantity']; ?> <html> <body> <form method="post" action="<?php echo getPurchaseLink('1Opp2p11M', $csvfile, $force_platform = "", $quantity); ?>"> <div class="comp"> <label class="font_12" for="quantity"># of PCs</label><br/> <select class="font_12" id="quantity" name="quantity"> <option value="10">10 PCs</option> <option value="25">25 PCs</option> <option value="50">50 PCs</option> <option value="99">99 PCs</option> </select> </div> <div class="div_small"><span class="font_12"><br/>for</span></div> <input name="submit" id="button_addtocart" type="submit" value="Submit" class="checkout" /> </form> </body> </html>