I have a problem. I'm a newbie to PHP and am attempting to code an echo function for a product information form.
FORM USED FOR:
This form is being used as a means to gather input text and checkbox data and echo it into another .php page so it can render/display that same collected form data into the form action="grid-maker.php"
page with predefined html content, essentially creating the end result, which is a pinterest-type product info grid block that displays in it an img, the name of product, description, price, etc,...
PROBLEM
I am using the simple <?php echo $_GET[''] ?>
to get things like the name, price, description... that was easy, the hard part for me is trying to use this echo function to deliver html content that varies in color and filled with input="" label="" div class=""
's using checkboxes that are checked, code example is shown below.
<div class="checkbox-purple">
<input type="checkbox" name="Color:_Purple" id="sku0001-purple" value="Yes">
<label for="sku0001-purple"></label>
</div>
<div class="checkbox-orange">
<input type="checkbox" name="Color:_Orange" id="sku0001-orange" value="Yes">
<label for="sku0001-orange"></label>
</div>
</code>
This type of html is what I want to send over to the new .php page everytime a checkbox is checked but all my attempts have failed.
I tried this first:
<?php
if(isset($GET['Color:_Purple']) &&
$GET['Color:_Purple'] == 'Yes')
{
echo "<div class='checkbox-purple'><input type='checkbox' name='Color:_Purple' id='sku0001-purple' value='Yes' class='SKU0001_adjust'><label for='sku0001-purple'></label></div>";
}
?>
this didn't work for me, I placed this code as is in between the div that I wanted it to be displayed in the product-maker.php page but it didn't show up.
After much newbie tinkering every which way I came to this
<?php echo "<div class='checkbox-purple'><input type='checkbox' name='Color:_Purple' id='<echo $_GET['sku']-purple' value='Yes' class='<echo $_GET['sku']_adjust'><label for='echo $_GET['sku']-purple'></label></div>"; ?>
this did work in injecting the code into the page, but it was not attached to the checkbox, nor am I confident about those single quotations inside the div's and stuff, not sure how this would affect the echo functions placed inside.
I tried many other methods that I have lost track of. Any and all recommendations would be helpful, and semi-detailed instructions would be appreciated since I'm new to PHP.
Thanks everyone.