Created
February 24, 2019 18:12
-
-
Save drptinfo/95478031909cfe44b1e99723ca44af72 to your computer and use it in GitHub Desktop.
php insert no banco
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//session_start(); | |
//include_once("conexao_bd.php"); | |
date_default_timezone_set("America/Sao_Paulo"); | |
header('Content-type: text/plain; charset=utf-8'); | |
$date = date('Y-m-d H:i:s'); | |
$nome = $_POST['nome']; | |
$telefone = $_POST['telefone']; | |
$unidposto = $_POST['unidposto']; | |
$email = $_POST['email']; | |
$cep = $_POST['cep']; | |
$rua = $_POST['rua']; | |
$bairro = $_POST['bairro']; | |
$cidade = $_POST['cidade']; | |
$numero = $_POST['numero']; | |
$complemento = $_POST['complemento']; | |
$referencia = $_POST['referencia']; | |
$exame = $_POST['exame']; | |
$idusuario = $_POST['idusuario']; | |
//$nome2 = mysql_real_escape_string($nome); | |
//$telefone2 = mysql_real_escape_string($telefone); | |
if(!empty($nome) and | |
!empty($telefone) and | |
!empty($cep) and | |
!empty($rua) and | |
!empty($bairro) and | |
!empty($numero) and | |
!empty($exame)) | |
{ | |
$servidor = "localhost"; | |
$usuario = "root"; | |
$senha = ""; | |
$dbname = ""; | |
//Criar a conexao | |
$conn = mysqli_connect($servidor, $usuario, $senha, $dbname); | |
// $banco = mysql_select_db("tadexpre_cliente"); | |
$insert = mysqli_query($conn,"INSERT INTO cliente (DT_REG,NOME_PAC,TEL,STS,ID_U_P,OBS,ID_COL,CEP,RUA,NUMERO,COMPLEMENTO,BAIRRO, | |
CIDADE,PONTO_REF,EMAIL,ID_EXAME) values | |
('$date',UPPER('$nome'),'$telefone','1','$unidposto','Null','$idusuario','$cep','$rua','$numero', | |
UPPER('$complemento'),'$bairro','$cidade',UPPER('$referencia'),'$email',UPPER('$exame'))") or die ("Erro"); | |
echo 'Cadastrado com sucesso!'; | |
} | |
else | |
{ | |
echo 'Preencher todos os campos!'; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment