mirror of
https://github.com/frontendnetwork/vegancheck.me
synced 2024-11-15 08:37:09 +00:00
Added JQuery for form
This commit is contained in:
parent
6e63b53e94
commit
779225fa2b
1 changed files with 20 additions and 17 deletions
37
script.php
37
script.php
|
@ -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.";
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Reference in a new issue