$_POST retornando undefined
Boa tarde,
estou com um formulário, e ao clicar em submit envia para a mesma pagina só que quando tento
pegar os dados dos input text com o método POST, está retornando undefined
coloquei um alert do javascript só pra ver o retorno
<?php
session_start();
include('conecta.php');
$listaproduto = mysql_query("SELECT * FROM carrinho AS c INNER JOIN produtos AS p ON c.codigoproduto = p.codigoproduto WHERE c.sessionid = '".$_SESSION['sessionid']."'");
if(isset($_POST['envia']))
{
$OPCAO = $_POST['envia'];
echo "<script>alert($OPCAO);</script>";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" href="estilo.css" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sem título</title>
<script language="javascript1.5" src="functions.js"></script>
</head>
<body>
<div id="pagina">
<?php include("header.php"); ?>
<div id="corpo">
<h3>Produtos em seu carrinho de compras</h3>
<table width="800px" id="tableCarrinho" cellspacing="0">
<tr>
<td class="colunas" width="590">Medicamento</td>
<td class="colunas" width="70">Preço Unit.</td>
<td class="colunas" width="70">Quantidade</td>
<td class="colunas" width="70">Total</td>
</tr>
<?php while($resultado = mysql_fetch_object($listaproduto)){ ?>
<tr>
<td class="colunas prod"><?php echo $resultado->descricao; ?></td>
<td class="colunas prod"><?php echo $resultado->valorunit; ?></td>
<td class="colunas prod"><?php echo $resultado->quantidade; ?></td>
<td class="colunas prod"><?php echo $resultado->total; ?></td>
<?php } ?>
</tr>
</table>
<div id="containerEndereco">
<form action="<?php $_SERVER['PHP_SELF']; ?>" method="post">
<table width="auto" style="margin:0 auto;">
<tr>
<td width="50px"><label>Nome</label></td>
<td colspan="3"><input type="text" name='txtnome' size="65" maxlength="50" onchange="this.value = this.value.toUpperCase();" /></td>
</tr>
<tr>
<td><label>CPF</label></td>
<td><input type="text" name="txtcpf" id="cpf" onblur="validaCpf(this.value);" onkeydown="mascaraCpf();" maxlength="14" /></td>
<td><label>Telefone</label></td>
<td><input type="text" name="txttelefone" size="12" id="telefone" onkeydown="mascaraTelefone();"/></td>
</tr>
<tr>
<td><label>Endereço</label></td>
<td><input type="text" name="txtendereco" size="35" maxlength="50" onchange="this.value = this.value.toUpperCase();"/></td>
<td><label>Numero</label></td>
<td><input type="text" name="txtnumero" size="12" maxlength="7" onchange="this.value = this.value.toUpperCase();"/></td>
</tr>
<tr>
<td><label>Bairro</label></td>
<td colspan="3"><input type="text" name="txtbairro" size="65" maxlength="50" onchange="this.value = this.value.toUpperCase();"/></td>
</tr>
</table>
</div>
<div id="botaoEnviaPedido">
<input type="submit" name="envia" value="Enviar Pedido" />
</form>
</div>
</div>
<?php include("footer.php"); ?>
</div>
</body>
</html>
obrigado pela atenção desde já!
Att.
Danilo Milan
Discussão (3)
Carregando comentários...