não consigo enviar os dados da select para o bd
Mesa.php
<?php
include_once 'idioma/common.php';
session_start(); //sempre session_start antes de usar sessions
if ( isset($_SESSION['garcom']) ) {
}
else {
header ("location:logar.php");
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title><?php echo $lang['PAGE_TITLE']; ?></title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="jquery.mobile.structure-1.0.1.css" />
<link rel="apple-touch-icon" href="images/launch_icon_57.png" />
<link rel="apple-touch-icon" sizes="72x72" href="images/launch_icon_72.png" />
<link rel="apple-touch-icon" sizes="114x114" href="images/launch_icon_114.png" />
<link rel="stylesheet" href="jquery.mobile-1.0.1.css" />
<link rel="stylesheet" href="custom.css" />
<script src="js/jquery-1.7.1.min.js"></script>
<script src="js/jquery.mobile-1.0.1.min.js"></script>
</head>
<body>
<div data-role="page" id="home" data-theme="c">
<div data-role="content">
<div id="branding">
</div>
<div id="language">
<!--<a href="index.php?lang=pt"><img src="images/lang_br.png" /></a>
<a href="index.php?lang=fr"><img src="images/lang_fr.png" /></a>-->
</div>
<div class="choice_list">
<h1><?php echo $lang['CARDAPIO_TITULO1']; ?></h1>
<ul data-role="listview" data-inset="true" >
<form id='form-id' method='post' action='gerencia/adddb.php' target='_self'><input type='hidden' name='cod' value='$id'>
<select name='lugar' data-native-menu='false' data-theme='c' >
<option value='l1'>L1</option>
<option value='l2'>L2</option>
<option value='l3'>L3</option>
<option value='l4'>L4</option>
<option value='l5'>L5</option>
<option value='l6'>L6</option>
</select>
<select name="menu" onChange="location=document.jump.menu.options[document.jump.menu.selectedIndex].value;"value="go">
<option value="[http://drink.php">DRINK](http://drink.php)
<option value="[http://bebida.php">BEBIDA](http://bebida.php)
<option value="[http://entrada.php">ENTRADA](http://entrada.php)
<option value="[http://grelhado.php">GRELHADO](http://grelhado.php)
<option value="[http://sugestoes.php">SUGESTÃES](http://sugestoes.php)
<option value="[http://sobremesa.php">SOBREMESA](http://sobremesa.php)
</select>
<select name='quant' data-native-menu='false' data-theme='c' >
<option value='0'>0</option>
<option value='1'>1</option>
<option value='2'>2</option>
<option value='3'>3</option>
<option value='4'>4</option>
<option value='5'>5</option>
<option value='6'>6</option>
</select>
</form>
<form name="jump">
</form>
<form id='form-id' method='post' action='gerencia/adddb.php' target='_self'><input type='hidden' name='cod' value='$id'>
<?php
include "gerencia/config.php";
//while=uail query=kuieri
$sql = mysql_query("select * from itens where categoria='pratos' order by nome", $conexao);
while($linha = mysql_fetch_array($sql)){
$id = $linha["id"];
$nome = $linha["nome"];
$imgid = $linha["img"];
echo "<input type='submit' value='$nome'></form>";
}
mysql_close($conexao);
?>
</ul>
</div>
</div>
</div>
</body>
</html>
Adddb.php
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<?php
session_start(); //sempre session_start antes de usar sessions
session_start("garcom");
include "config.php";
//PRIMEIRO IF- VERIFICA SE O CLIENTE JA POSSUI UMA MESA/JA REGISTROU ALGUM PEDIDO
if ( isset($_SESSION['mesa']) ) {
$cod = $_POST["cod"];
$quant = $_POST["quant"];
$data = date('Y-m-d H:i:s'); // Formato DATETIME: 2013-06-30 18:42:57
if ($quant == '0'){
echo "<center><h3>Você não selecionou nenhum prato/bebida!</h3><br>Clique <a href='javascript:window.history.go(-1)'>aqui</a> para voltar.<br>ou clique <a href='../drinks.php'>aqui</a> para ver os nossos drinks.</center><br>";
}
else {
$mesa = $_SESSION['mesa'];
$sql = mysql_query("INSERT INTO pedidos (
`num_pedido` ,
`id` ,
`quant` ,
`mesa` ,
`atendente` ,
`cliente` ,
data
)
VALUES (
NULL , '$cod', '$quant', '$mesa', '$atendente', '0', '$data');", $conexao)or die("Error: " . mysql_error());
if (mysql_affected_rows() == 1) {
echo "<h3 align=center>Pedido Registrado!<h3>";
} else {
echo "<h3 align=center>falha no cadastro!<br></h3><h5 align='center'></h5>";
}
$sql = mysql_query("UPDATE mesas SET status = '1' where numero = '$mesa' ", $conexao)or die("Error: " . mysql_error());
//Cria sessão com o numero da mesa, para localizar pedido posteriormente.
session_start("mesa");
$_SESSION["mesa"] = "$mesa";
//echo 'Pedido mesa: '.$mesa;
mysql_close($conexao); }
header ("location:../carrinho.php");
}
//SEGUNDO IF- CLIENTE NÃO REALIZOU NENHUM PEDIDO ANTES. O ALOCAREMOS EM ALGUMA MESA
else {
$cod = $_POST["cod"];
$quant = $_POST["quant"];
$atendente = $_SESSION["garcomid"];
$data = date('Y-m-d H:i:s'); // Formato DATETIME: 2013-06-30 18:42:57
if ($quant == '0'){
echo "<center><h3>Você não selecionou nenhum prato!</h3><br>Clique <a href='javascript:window.history.go(-1)'>aqui</a> para voltar.<br>ou clique <a href='../drinks.php'>aqui</a> para ver os nossos drinks.</center><br>";
}
else {
$sql0 = mysql_query("SELECT numero FROM mesas WHERE STATUS = '0' LIMIT 1", $conexao);
while($linha = mysql_fetch_array($sql0)){
$mesa = $linha["numero"];
}
$sql = mysql_query("INSERT INTO pedidos (
`num_pedido` ,
`id` ,
`quant` ,
`mesa` ,
`atendente` ,
`cliente` ,
data
)
VALUES (
NULL , '$cod', '$quant', '$mesa', '$atendente', '0', '$data');", $conexao)or die("Error: " . mysql_error());
if (mysql_affected_rows() == 1) {
echo "<h3 align=center>Pedido Registrado!<h3>";
} else {
echo "<h3 align=center>falha no cadastro!<br></h3><h5 align='center'></h5>";
}
$sql = mysql_query("UPDATE mesas SET status = '1' where numero = '$mesa' ", $conexao)or die("Error: " . mysql_error());
//Cria sessão com o numero da mesa, para localizar pedido posteriormente.
session_start("mesa");
$_SESSION["mesa"] = "$mesa";
//echo 'Pedido mesa: '.$mesa;
mysql_close($conexao); }
header ("location:../carrinho.php");
}
?>
</body>
</html>Discussão (2)
Carregando comentários...