Esempio n. 1
0
<?php

include_once 'ingrediente.php';
$ingrediente = new ingrediente();
echo $ingrediente->getJSONIngredientes();
Esempio n. 2
0
<form action="#" method="post">
	<input type="text" name="nombre" />
	<input type="text" name="comentario" />
	
	<input type="submit" name="nuevo_ingrediente" value="nuevo_ingrediente" />
	<input type="submit" name="ver_ingrediente" value="ver_ingrediente" />
</form>
<?php 
require 'clases/ingredientes.class.php';
$ing = new ingrediente();
$ing->get_ingredientes();
echo "<select>";
$ing->seleccionar_ingrediente();
echo "<select>";
if (isset($_POST['nuevo_ingrediente'])) {
    $nombre = $_POST['nombre'];
    isset($_POST['comentario']) ? $comentario = $_POST['comentario'] : ($comentario = NULL);
    $i = new ingrediente();
    $i->insertar_ingrediente($nombre, $comentario);
}
if (isset($_POST['ver_ingrediente'])) {
    $i = new ingrediente();
    $i->get_ingredientes();
}
<?php

include_once 'ingrediente.php';
$ingrediente = new ingrediente();
if (isset($_POST['nombre']) && isset($_POST['descripcion'])) {
    echo $ingrediente->getJSONInsertIngrediente($_POST['nombre'], $_POST['descripcion']);
} else {
    echo $ingrediente->getJSONError('insert', 'Error en el envio de datos');
}