Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to Secure My Code
    primarykey
    data
    text
    <p>I'm writing a simple web-based site for a company to display products on their site. It needs to be fairly easy to maintain. I'm not able to use a database. I'm using a multidimensional array to store the product information and retrieving it with a <strong>product key</strong>.</p> <p>My main concern is security. I have a very limited amount of time I can spend on this - so, I don't have the bandwidth to build anything more serious. If you see anything that looks obviously bad, please let me know how I can patch it.</p> <p>Here is an example URL with the product key: <a href="http://example.com/products.php?productKey=widget" rel="nofollow">http://example.com/products.php?productKey=widget</a></p> <p>Here is the code that gets the product key, verifies it's valid, and retrieves the product information:</p> <pre><code>// obtain merchandise variables include 'merch.vars.php'; // assign a default value $productKey = 'placeholder'; // check to see if a value was passed if (isset($_GET["productKey"])) { // create array of product keys $productArrayKeys = array_keys($product); // check if value passed to page exists in product key array if (in_array($_GET["productKey"], $productArrayKeys)) { // value exists - assign to $productKey $productKey = $_GET["productKey"]; } } </code></pre> <p>Here is an example of the product multidimensional array:</p> <pre><code>$product = array( "placeholder" =&gt; array( item_title =&gt; "Placeholder Title", item_image_url =&gt; "placeholder.png", item_price =&gt; "0.00", item_description =&gt; "Placeholder Description", item_quantity =&gt; 1, product_icons =&gt; false ), "widget" =&gt; array( item_title =&gt; "Product Title", item_image_url =&gt; "widget.png", item_price =&gt; "15.00", item_description =&gt; "Product Description", item_quantity =&gt; 1, item_category =&gt; array( small =&gt; "Small", medium =&gt; "Medium", large =&gt; "Large", Xlarge =&gt; "XLarge" ), product_icons =&gt; true ) ); </code></pre>
    singulars
    1. This table or related slice is empty.
    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