2
html:
<!doctype html>
<html lang="pt-br">
<head>
<meta charset="utf-8">
<title>Untitled Page</title>
<meta name="generator" content="WYSIWYG Web Builder 12">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="novo.css" rel="stylesheet">
<link href="particular.css" rel="stylesheet">
<script src="jquery-1.12.4.min.js"></script>
<script src="jquery-ui.min.js"></script>
<script src="wb.slideshow.min.js"></script>
<script>
function ValidateLayer1(theForm)
{
var regexp;
if (theForm.Combobox1.selectedIndex < 0)
{
alert("Please select one of the \"uf\" options.");
theForm.Combobox1.focus();
return false;
}
if (theForm.Combobox2.selectedIndex < 0)
{
alert("Please select one of the \"sexo\" options.");
theForm.Combobox2.focus();
return false;
}
return true;
}
</script>
<script>
$(document).ready(function()
{
$("#SlideShow1").slideshow(
{
interval: 5000,
type: 'sequence',
effect: 'fade',
direction: '',
pagination: false,
fullscreen: 0,
maxWidth: 1920,
effectlength: 2000
});
});
</script>
</head>
<body>
<div id="container">
<a href="http://www.wysiwygwebbuilder.com" target="_blank"><img src="images/builtwithwwb12.png" alt="WYSIWYG Web Builder" style="position:absolute;left:626px;top:967px;border-width:0;z-index:250"></a>
</div>
<div id="wb_LayoutGrid2">
<div id="LayoutGrid2">
<div class="row">
<div class="col-1">
<div id="wb_Text2">
<span style="color:#FFFFFF;font-family:Tahoma;font-size:15px;letter-spacing:1.07px;"><strong>Obrigado por acessar o Dr.Solidario!</strong></span>
</div>
</div>
</div>
</div>
</div>
<div id="wb_LayoutGrid1">
<div id="LayoutGrid1">
<div class="row">
<div class="col-1">
<hr id="Line1" style="display:block;width:100%;height:25px;z-index:1;">
<div id="wb_Image1" style="display:inline-block;width:397px;height:130px;z-index:2;">
<img src="images/logo (1).png" id="Image1" alt="">
</div>
<div id="wb_Text3">
<span style="color:#000000;font-family:Tahoma;font-size:15px;letter-spacing:1.07px;">Sempre bom vê-lo aqui!</span>
</div>
</div>
<div class="col-2">
</div>
<div class="col-3">
<div id="wb_Image2" style="display:inline-block;width:160px;height:118px;z-index:4;">
<img src="images/img_atendimento.png" id="Image2" alt="">
</div>
<div id="wb_Text1">
<span style="color:#000000;font-family:Tahoma;font-size:24px;"><strong>Central de atendimento<br></strong></span><span style="color:#833E90;font-family:Tahoma;font-size:24px;">(21) 3258-1236 / (21) 3258-0581</span>
</div>
<hr id="Line2" style="display:block;width:100%;height:16px;z-index:6;">
</div>
</div>
</div>
</div>
<div id="Layer1" style="position:relative;text-align:center;width:100%;height:596px;float:left;clear:left;display:block;z-index:27;">
<div id="Layer1_Container" style="width:1340px;position:relative;margin-left:auto;margin-right:auto;text-align:left;">
<form name="form" method="POST" action="insert.php">
<input type="text" id="Editbox1" style="position:absolute;left:173px;top:48px;width:984px;height:16px;line-height:16px;z-index:7;" name="nome" value="" autofocus spellcheck="false" placeholder="NOME:">
<input type="text" id="Editbox2" style="position:absolute;left:173px;top:135px;width:234px;height:16px;line-height:16px;z-index:8;" name="cpf" value="" spellcheck="false" placeholder="CPF:">
<input type="text" id="Editbox3" style="position:absolute;left:519px;top:135px;width:270px;height:16px;line-height:16px;z-index:9;" name="identidade" value="" spellcheck="false" placeholder="IDENTIDADE:">
<input type="text" id="Editbox4" style="position:absolute;left:897px;top:135px;width:260px;height:16px;line-height:16px;z-index:10;" name="telefone" value="" spellcheck="false" placeholder="TELEFONE:">
<input type="text" id="Editbox5" style="position:absolute;left:173px;top:223px;width:233px;height:16px;line-height:16px;z-index:11;" name="celular" value="" spellcheck="false" placeholder="CELUAR:">
<input type="text" id="Editbox6" style="position:absolute;left:519px;top:223px;width:639px;height:16px;line-height:16px;z-index:12;" name="email" value="" spellcheck="false" placeholder="EMAIL:">
<input type="text" id="Editbox7" style="position:absolute;left:173px;top:304px;width:231px;height:16px;line-height:16px;z-index:13;" name="cep" value="" spellcheck="false" placeholder="CEP:">
<input type="text" id="Editbox8" style="position:absolute;left:519px;top:304px;width:639px;height:16px;line-height:16px;z-index:14;" name="endereco" value="" spellcheck="false" placeholder="ENDERECO:">
<input type="text" id="Editbox9" style="position:absolute;left:173px;top:388px;width:443px;height:16px;line-height:16px;z-index:15;" name="complemento" value="" spellcheck="false" placeholder="COMPLEMENTO:">
<input type="text" id="Editbox10" style="position:absolute;left:680px;top:388px;width:477px;height:16px;line-height:16px;z-index:16;" name="bairro" value="" spellcheck="false" placeholder="BAIRRO:">
<select name="uf" size="1" id="Combobox1" style="position:absolute;left:608px;top:476px;width:72px;height:28px;z-index:17;">
<option selected>UF</option>
<option>RJ</option>
<option>SP</option>
</select>
<select name="sexo" size="1" id="Combobox2" style="position:absolute;left:719px;top:476px;width:170px;height:28px;z-index:18;">
<option selected>SELECIONE O SEXO</option>
<option>MASCULINO</option>
<option>FEMININO</option>
</select>
<input type="text" id="Editbox11" style="position:absolute;left:917px;top:477px;width:103px;height:16px;line-height:16px;z-index:19;" name="idade" value="" spellcheck="false" placeholder="IDADE:">
<input type="text" id="Editbox12" style="position:absolute;left:1055px;top:477px;width:103px;height:16px;line-height:16px;z-index:20;" name="peso" value="" spellcheck="false" placeholder="PESO:">
<input type="submit" id="Button1" name="" value="ENVIAR" style="position:absolute;left:1072px;top:547px;width:96px;height:25px;z-index:21;">
<input type="text" id="Editbox13" style="position:absolute;left:173px;top:477px;width:377px;height:16px;line-height:16px;z-index:22;" name="cidade" value="" spellcheck="false" placeholder="CIDADE:">
</div>
</div>
<div id="wb_LayoutGrid5">
<div id="LayoutGrid5">
<div class="row">
<div class="col-1">
<hr id="Line5" style="display:block;width:100%;height:17px;z-index:23;">
<div id="wb_Image3" style="display:inline-block;width:320px;height:300px;z-index:24;">
<img src="images/pop_up2.png" id="Image3" alt="">
</div>
</div>
<div class="col-2">
<ul id="SlideShow1" style="display:inline-block;position:relative;width:803px;height:330px;z-index:25;">
<li><img class="image" src="images/1.png" alt="" title=""></li>
<li><img class="image" src="images/2.png" style="display:none;" alt="" title=""></li>
<li><img class="image" src="images/3.png" style="display:none;" alt="" title=""></li>
</ul>
</div>
</div>
</div>
</div>
</form></body>
</html>
php:
<?php
include "conectar.php";
//comando para iserir dados direto do formulário para o banco de dados
$vnome=$_POST['nome'];
$vcpf=$_POST['cpf'];
$videntidade=$_POST["identidade"];
$vtelefone=$_POST["telefone"];
$vcelular=$_POST["celular"];
$vemail=$_POST["email"];
$vcep=$_POST["cep"];
$vendereco=$_POST["endereco"];
$vcomplemento=$_POST["complemento"];
$vbairro=$_POST["bairro"];
$vcidade=$_POST["cidade"];
$vuf=$_POST["uf"];
$vsexo=$_POST["sexo"];
$vidade=$_POST["idade"];
$vpeso=$_POST["peso"];
$sql="INSERT INTO solidario (nome,cpf,identidade,telefone,celular,email,cep,endereco,complemento,bairro,cidade,uf,sexo,idade,peso)
VALUES ('$vnome', '$vcpf', '$videntidade', '$vtelefone', '$vcelular', '$vemail', '$vcep', '$vendereco', '$vcomplemento', '$vbairro', '$vcidade', '$vuf', '$vsexo', '$vidade', '$vpeso')";
$res=mysqli_query($con,$sql);
$num=mysqli_affected_rows($con);
if($num == 1){
echo"registro cadastrado";
}else{
echo" não gravado";
}
mysqli_close($con);
?>
I could explain better what happens?
– rray
If you (who probably is the one who made the code) don’t know, imagine that we have no idea what this is. Please explain the problem.
– Jéf Bueno
Good afternoon. How is your table structure? Can you post for analysis? Thank you.
– Rodrigo Sandrini
By the vague description of the problem your key may be duplicated. Change your code to:
$res=mysqli_query($con,$sql) or die(mysqli_error($con));
thus displays the bank error (if you have).– rray
I’ll try to be clearer, I’m sorry.... I created this html and made the php code to insert data into the table... inserted once and then no more... no error , simply "not saved" as per ELSE!
– Flavio Cordas
-- phpMyAdmin SQL Dump -- version 4.7.0 CREATE TABLE
solidario
(nome
varchar(200) NOT NULL,cpf
int(15) NOT NULL,identidade
varchar(17) NOT NULL,telefone
varchar(15) NOT NULL,celular
varchar(15) NOT NULL,email
varchar(150) NOT NULL,cep
varchar(15) NOT NULL,endereco
varchar(150) NOT NULL,complemento
varchar(150) NOT NULL,bairro
varchar(150) NOT NULL,cidade
varchar(80) NOT NULL,uf
varchar(5) NOT NULL,sexo
varchar(25) NOT NULL,idade
varchar(3) NOT NULL,peso
varchar(6) NOT NULL– Flavio Cordas
Thanks rray solved the problem!!
– Flavio Cordas
Which field was your primary key before?
– rray
-rray was Cpf but following his tip I decided, thank you very much!
– Flavio Cordas