Added JQuery for form

This commit is contained in:
Philip 2021-08-21 14:49:00 +02:00
parent 6e63b53e94
commit 779225fa2b

View file

@ -3,25 +3,28 @@
// Vegan uknown: https://world.openfoodfacts.org/api/v0/product/4008638170726.json
// Not vegan: 5000159404259
$barcode = $_GET['barcode'];
$barcode = $_POST['barcode'];
$data = file_get_contents('https://world.openfoodfacts.org/api/v0/product/'.$barcode.'.json');
$product = json_decode($data);
$array = $product->product->ingredients_analysis_tags;
$name = $product->product->product_name;
if (in_array("en:non-vegan", $array)) {
echo '"'.$name.'" is most likely not Vegan';
}
elseif (in_array("en:vegan-status-unknown", $array)) {
echo 'We are not sure if "'.$name.'" is vegan or not.';
}
elseif (in_array("en:vegan", $array)) {
echo '"'.$name.'" is Vegan!';
if (empty($barcode)){
echo "Please enter a valid barcode.";
}
else {
echo "This product is not in our database yet.";
$data = file_get_contents('https://world.openfoodfacts.org/api/v0/product/'.$barcode.'.json');
$product = json_decode($data);
$array = $product->product->ingredients_analysis_tags;
$name = $product->product->product_name;
if (in_array("en:non-vegan", $array)) {
echo '"'.$name.'" is most likely not Vegan';
}
elseif (in_array("en:vegan-status-unknown", $array)) {
echo 'We are not sure if "'.$name.'" is vegan or not.';
}
elseif (in_array("en:vegan", $array)) {
echo '"'.$name.'" is Vegan!';
}
else {
echo "This product is not in our database yet.";
}
}
?>