I am getting an undefined variable when I submit a form. It successfully prints out the information using an echo but not outside the get function. I need it to get the previous product ID's, which the get function does. Then I need it to insert into the sql query, that is not working. I'm afraid its a bracket error. Here are snippets of my code:
if (isset($_GET['productID'])) {
$productID = ($_GET['productID']);
echo $productID; //echos successfully
}
// Doesn't echo here
$query = "INSERT INTO orders (productID) VALUES ('$productID' )";
$results = @mysqli_query ($conn, $query);
?>
<form class="form-horizontal" role="form" method="post" action="checkout.php">
<div class="form-group">
<div class="form-group">
<div class="form-group">
<div class="col-sm-12 col-sm-offset-2">
<input type="submit" name="submit" value="Submit" class="btn btn-default"/>
</div>
</div>
</form>
</div>
<?php
include ('footer.php');
?>