<?php

$filename = 'c_leitura.php';

if (!file_exists($filename)) {
    header("Location: error.php");
    exit;
}

include 'c_leitura.php';
require_once("db.php");

if (!isset ($_GET['idprod']))
{
	http_response_code (400);
	die ("idprod não informado");
}

$idprod = $_GET['idprod'];

$query = "SELECT * FROM `tablet` WHERE idprod = '$idprod'";
$result = mysql_query($query) or die(mysql_error());

if (mysql_num_rows ($result) == 0)
{
	http_response_code (400);
	die ("Tablet inexistente");
}

$query = "UPDATE tablet SET destrava = 0 WHERE idprod = '$idprod'";
mysql_query($query) or die(mysql_error());

echo ("OK");

?>