Jump to content
Fórum Script Brasil
  • 0

mensagem quando lançado dados no formulario


Ljrbrasil

Question

Pessoal,

tenho o formulario abaixo para importação de informaçoes para o banco e gostaria que quando fosse lançado uma informação de CPF e este CPF já estive-se no banco de dados o sistema envia-se ao usuario uma mensagem informando que já existe e perguntado se ele gostaria de continuar a carregar os dados.

alguém podem me ajudar?

<?php

//arquivo de conexão com o banco de dados
require('conecta.php');

//pegando variáveis
$filial      =  $_POST ['filial'];
$regional    =  $_POST ['regional'];
$pedido      =  $_POST ['pedido'];
$data        =  $_POST ['data'];
$hora        =  strftime('%H:%M:S');
$acesso      =  $_POST ['acesso'];
$cliente     =  $_POST ['cliente'];
$cpf         =  $_POST ['cpf'];
$plano       =  $_POST ['plano'];
$backoffice  =  $_POST ['backoffice'];

//inserindo dados na tabela livrodevisitas
$sqlinsert = "INSERT INTO livrodevisitas (filial, regional, pedido, data, hora, acesso, cliente, cpf, plano, backoffice)
VALUES ('$filial', '$regional', '$pedido', '$data', '$hora', '$acesso', '$cliente', '$cpf', '$plano', '$backoffice')";
              
mysql_query($sqlinsert) or die ("Não foi possível inserir os dados");

echo"
<html>

<head>
<meta http-equiv=\"Content-Language\" content=\"pt-br\">
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1252\">
<title>Sua venda foi enviada.</title>
<link rel = \"stylesheet\" type = \"text/css\" href = \"css.css\" />
<style>
<!--
.ms-simple1-main { border-left-style: none; border-right-style: none;
               border-top: 1.5pt solid green; border-bottom: 1.5pt solid green }
.ms-simple1-tl { border-left-style: none; border-right-style: none; border-top-style: none;
               border-bottom: .75pt solid green }
.ms-simple1-left { border-style: none }
.ms-simple1-even { border-style: none }
-->
</style>
</head>

<body>

<p align=\"center\" style=\"margin-top: 0; margin-bottom: 0\">
<hr size=\"1\" width=\"50%\">
<p align=\"center\" style=\"margin-top: 0; margin-bottom: 0\">
<font face=\"Century Gothic\" color=\"#008000\">Venda Enviada</font></p>
<hr size=\"1\" width=\"50%\">
<div align=\"center\">
    <table border=\"0\" width=\"51%\" id=\"table1\" class=\"ms-simple1-main\">
        <!-- fpstyle: 1,011111100 -->
        <tr>
            <td colspan=\"2\" class=\"ms-simple1-tl\">
            <font face=\"Century Gothic\" size=\"2\">Data: $data&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            Hora: $hora</font></td>
        </tr>
        <tr>
            <td width=\26%\" class=\"ms-simple1-left\">
            <font face=\"Century Gothic\" size=\"2\">Filial</font></td>
            <td width=\"73%\" class=\"ms-simple1-even\">$filial</td>
        </tr>
        <tr>
            <td width=\"26%\" class=\"ms-simple1-left\">
            <font face=\"Century Gothic\" size=\"2\">Regional</font></td>
            <td width=\"73%\" class=\"ms-simple1-even\">$regional</td>
        </tr>
        <tr>
            <td width=\"26%\" class=\"ms-simple1-left\">
            <font face=\"Century Gothic\" size=\"2\">Pedido:</font></td>
            <td width=\"73%\" class=\"ms-simple1-even\">$pedido</td>
        </tr>
        <tr>
            <td width=\"26%\" class=\"ms-simple1-left\">
            <font face=\"Century Gothic\" size=\"2\">Data:</font></td>
            <td width=\"73%\" class=\"ms-simple1-even\">$data</td>
        </tr>
        <tr>
            <td width=\"26%\" class=\"ms-simple1-left\">
            <font face=\"Century Gothic\" size=\"2\">acesso:</font></td>
            <td width=\"73%\" class=\"ms-simple1-even\">$acesso</td>
        </tr>
        <tr>
            <td width=\"26%\" class=\"ms-simple1-left\">
            <font face=\"Century Gothic\" size=\"2\">Cliente:</font></td>
            <td width=\"73%\" class=\"ms-simple1-even\">$cliente</td>
        </tr>
        <tr>
            <td width=\"26%\" class=\"ms-simple1-left\">
            <font face=\"Century Gothic\" size=\"2\">CPF:</font></td>
            <td width=\"73%\" class=\"ms-simple1-even\">$cpf</td>
        </tr>
        <tr>
            <td width=\"26%\" class=\"ms-simple1-left\">
            <font face=\"Century Gothic\" size=\"2\">Plano:</font></td>
            <td width=\"73%\" class=\"ms-simple1-even\">$plano</td>
        </tr>
         <tr>
            <td width=\"26%\" class=\"ms-simple1-left\">
            <font face=\"Century Gothic\" size=\"2\">Backoffice:</font></td>
            <td width=\"73%\" class=\"ms-simple1-even\">$backoffice</td>
        </tr>                        
    </table>
</div>

</body>

</html>";

echo '<meta http-equiv="refresh" content="5;URL=vendas.php" /> ' //redirecionar

?>

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Cara, existem n formas de fazer isso, você pode fazer isso com jQuery utilizando a evento LEAVE, ou seja, quando o foco sair do campo e for para o proximo ele vai pegar esse valor q está na input e buscar no banco pra ver se existe,

acho que um dos moderadores poderia mover o tópico para Javascript/DOM/Ajax, etc.

Abs.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152.2k
    • Total Posts
      652k
×
×
  • Create New...