Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Estou tendo problema com um formulário que fiz, alguma variáveis não são salvas na tabela e o campo data grava sempre o valor 000000 independente do número digitado.
Meu form
<?php include "header.php"; ?>
<title>Página de cadastro de clientes</title>
<link rel="stylesheet" type="text/css" href="css/estilo.css" media="screen" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script src="scripts/function_hidden.js"></script>
<script type="text/javascript">
function makeDate(id){
obj = document.getElementById(id);
vl = obj.value;
l = vl.toString().length;
switch(l){
case 2:
obj.value = vl + "/";
break;
case 5:
obj.value = vl + "/";
break;
}
}
</script>
<script type="text/javascript">
function makeTel(id){
obj = document.getElementById(id);
vl = obj.value;
l = vl.toString().length;
switch(l){
case 4:
obj.value = vl + "-";
break;
}
}
</script>
<script type="text/javascript">
function makeCep(id){
obj = document.getElementById(id);
vl = obj.value;
l = vl.toString().length;
switch(l){
case 2:
obj.value = vl + ".";
break;
case 6:
obj.value = vl + "-";
}
}
</script>
<?php
include "config.php";
//Recebe os dados do formulário
$nome = $_POST["nome"];
$apelido = $_POST["apelido"];
$email = $_POST["email"];
$nascimento = "{$_POST["dia"]}-{$_POST["mes"]}-{$_POST["ano"]}";
$telfx = $_POST["telfx"];
$cel = $_POST["cel"];
$cep = $_POST["cep"];
$moradia = $_POST["moradia"];
$endereco = $_POST["endereco"];
$numero = $_POST["numero"];
$ref = $_POST["ref"];
$bairro = $_POST["bairro"];
$cidade = $_POST["cidade"];
$bloco = $_POST["bloco"];
$numero_ap = $_POST["numero-ap"];
$localizacao = $_POST["localizacao"];
//Insere os dados no banco de dados dentro da tabela selecionada
$sql = "INSERT INTO cad_clientes (nome,apelido,email,nascimento,telfx,cel,cep,moradia,endereco,numero,ref,bairro,cidade,bloco,numero_ap)
VALUES ('$nome', '$apelido', '$email', '$nascimento', '$telfx', '$cel', '$cep', '$moradia', '$endereco', '$numero', '$ref', '$cidade', '$bairro', '$bloco', '$numero_ap', '$localizacao')";
$query = mysql_query($sql) or die(mysql_error());
if($query == true){
echo "Seu cadastro foi realizado com sucesso!\"<br />\"Em breve você receberá em seu e-mail atualizações.";echo mysql_error();
}?>
<div id="content">
<div id="conteudo-pg-cadastro">
<h1 id="titulo-pagina">Cadastro</h1>
<p class="texto-pg-cadastro">Faça seu cadastro e receba nossas novidades e atualizações em seu email.</p>
<form id="form1" name="form1" action="?=$_SERVER["PHP_SELF"]" method="POST" onsubmit="return validar();">
<fieldset>
<legend>Nome</legend>
<input type="text" id="nome" name="nome" maxlength="80" size="30" /></label>
</fieldset>
<fieldset>
<legend>Apelido</legend>
<input type="text" id="apelido" name="apelido" maxlength="50" size="30" /></label>
</fieldset>
<fieldset>
<legend>E-mail</legend>
<input type="text" id="email" name="email" maxlength="150" size="30" /></label>
</fieldset>
<fieldset>
<legend>Data de nascimento</legend>
<input type="text" id="data" name="data" maxlength="10" size="20" onkeyup="javascript:makeDate('data')" /></label>
</fieldset>
<fieldset>
<legend>Telefone fixo</legend>
<input type="text" id="telfx" name="telfx" maxlength="9" size="20" onkeyup="javascript:makeTel('telfx')" /></label>
</fieldset>
<fieldset>
<legend>Celular</legend>
<input type="text" id="cel" name="cel" maxlength="10" size="20" onkeyup="javascript:makeTel('cel')" /></label>
</fieldset>
<fieldset>
<legend>CEP</legend>
<input type="text" id="cep" name="cep" maxlength="15" size="20" onkeyup="javascript:makeCep('cep')" /></label>
</fieldset>
<fieldset>
<legend id="moradia">Tipo de Moradia:</legend>
<label><input type="radio" id="localizacao" name="localizacao" value="casa" /><span class="estilo1">Casa</span></label>
<label><input type="radio" id="localizacao" name="localizacao" value="apartamento" /><span class="estilo1">Apartamento</span></label>
<div id="esconde">
<div id="apartamento"><span class="estilo1">Bloco:</span><input type="text" name="bloco" id="bloco" maxlength="" size="5">
<span class="estilo1">N° Apto:</span><input type="text" name="numero-ap" id="numero" maxlength="" size="5"></div>
<div id="casa"><span class="estilo1">N°</span><input type="text" name="numero" id="numero" maxlength="" size="5" checked="checked"></div>
</div>
</fieldset>
<fieldset>
<legend>Endereço</legend>
<input type="text" name="endereco" id="endereco" maxlength="50" size="20" /></label>
</fieldset>
<fieldset>
<legend>Ponto de Referêcia</legend>
<input type="text" name="ref" id="ref" maxlength="80" size="30">
</fieldset>
<fieldset>
<legend>Cidade</legend>
<input type="text" name="cidade" id="cidade" maxlength="30" size="20" /></label>
</fieldset>
<fieldset>
<legend>Bairro</legend>
<input type="text" id="bairro" maxlength="30" size="20" /></label>
</fieldset>
<input type="submit" value="Cadastrar" id="botao" />
</form>
</div>
<?php include "footer.php"; ?>
Já revisei várias vezes e não estou achando os erros, podem me dar uma ajudinha? Se precisarem do código sql me avisem que eu posto tbm...
Carregando comentários...