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 product key.
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.
Here is an example URL with the product key: http://example.com/products.php?productKey=widget
Here is the code that gets the product key, verifies it's valid, and retrieves the product information:
// 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"]; } } Here is an example of the product multidimensional array:
$product = array( "placeholder" => array( item_title => "Placeholder Title", item_image_url => "placeholder.png", item_price => "0.00", item_description => "Placeholder Description", item_quantity => 1, product_icons => false ), "widget" => array( item_title => "Product Title", item_image_url => "widget.png", item_price => "15.00", item_description => "Product Description", item_quantity => 1, item_category => array( small => "Small", medium => "Medium", large => "Large", Xlarge => "XLarge" ), product_icons => true ) );