Viewing file: cadastro_boletins_eletronicos.php (6.27 KB) -rwxr-xr-x Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php //inclui o template de cabecalho
$title="IRPEN | Instituto de Registro Civil de Pessoas Naturais do Paraná - 2011"; include("cabecalho.php");
$txtNome=$_POST['txtNome'];
if($txtNome!="") { $txtEmail=$_POST['txtEmail'];
$sqlBuscaDados = " SELECT URE_Email,URE_RowID FROM usuario_recebem_email WHERE URE_Email ='$txtEmail' ";
$exeBuscaDados = mysqli_query($conexao,$sqlBuscaDados); $registros = mysqli_num_rows($exeBuscaDados);
if($registros!=0) { $rsBusca = mysqli_fetch_assoc($exeBuscaDados); $URE_RowID = $rsBusca['URE_RowID'];
//atualiza o registro para o contato receber email de boletin eletronico $sql = "UPDATE usuario_recebem_email SET URE_RecebeBoletin='S', URE_Nome='$txtNome' WHERE URE_RowID=".$URE_RowID; if($conexao->query($sql)) {
$conexao->commit(); $msg = "Cadastro efetuado com sucesso.";
} else { $msg = "Erro ao cadastrar e-mail."; } } else { //atualiza o registro para o contato receber email de boletin eletronico $sql = "INSERT INTO usuario_recebem_email (URE_Nome,URE_Email,URE_AtivoSN,URE_RecebeBoletin) VALUES ('$txtNome','$txtEmail','S','S')"; //echo($sql); if($conexao->query($sql)) {
$conexao->commit(); $msg = "Cadastro efetuado com sucesso.";
} else { $msg = "Erro ao cadastrar e-mail.";
} } ?> <script type="text/javascript"> alert("<?php echo $msg ?>"); window.location.href = "index.php"; </script> <?php }
?> <script language="javascript" type="text/javascript"> function checkMail(mail){ var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/); if(typeof(mail) == "string"){ if(er.test(mail)){ return true; } }else if(typeof(mail) == "object"){ if(er.test(mail.value)){ return true; } }else{ return false; } } function txtBoxFormat(objeto, sMask, evtKeyPress) { var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;
if(document.all) { // Internet Explorer nTecla = evtKeyPress.keyCode; } else if(document.layers) { // Nestcape nTecla = evtKeyPress.which; } else { nTecla = evtKeyPress.which; if (nTecla == 8) { return true; } }
sValue = objeto.value;
// Limpa todos os caracteres de formatação que // já estiverem no campo. sValue = sValue.toString().replace( "-", "" ); sValue = sValue.toString().replace( "-", "" ); sValue = sValue.toString().replace( ".", "" ); sValue = sValue.toString().replace( ".", "" ); sValue = sValue.toString().replace( "/", "" ); sValue = sValue.toString().replace( "/", "" ); sValue = sValue.toString().replace( ":", "" ); sValue = sValue.toString().replace( ":", "" ); sValue = sValue.toString().replace( "(", "" ); sValue = sValue.toString().replace( "(", "" ); sValue = sValue.toString().replace( ")", "" ); sValue = sValue.toString().replace( ")", "" ); sValue = sValue.toString().replace( " ", "" ); sValue = sValue.toString().replace( " ", "" ); fldLen = sValue.length; mskLen = sMask.length;
i = 0; nCount = 0; sCod = ""; mskLen = fldLen;
while (i <= mskLen) { bolMask = ((sMask.charAt(i) == "-") || (sMask.charAt(i) == ".") || (sMask.charAt(i) == "/") || (sMask.charAt(i) == ":")) bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " "))
if (bolMask) { sCod += sMask.charAt(i); mskLen++; } else { sCod += sValue.charAt(nCount); nCount++; }
i++; }
objeto.value = sCod;
if (nTecla != 8) { // backspace if (sMask.charAt(i-1) == "9") { // apenas números... return ((nTecla > 47) && (nTecla < 58)); } else { // qualquer caracter... return true; } } else { return true; } } function trim(str) { return str.replace(/^\s+|\s+$/g,""); }
function valida_formulario() {
if (trim(document.getElementById("txtNome").value) == "") { alert("Por favor, preencha o nome!"); document.getElementById("txtNome").focus(); return false; } else if (trim(document.getElementById("txtEmail").value) == "") { alert("Por favor, preencha o email!"); document.getElementById("txtEmail").value = ''; document.getElementById("txtEmail").focus(); return false; } else if (!checkMail(trim(document.getElementById("txtEmail").value))) { alert("Por favor, digite um email valido!"); document.getElementById("txtEmail").value = ''; document.getElementById("txtEmail").focus(); return false; } return true;
} </script>
<div id="cont_geral">
<div id="cont_esq">
<h2 class="tit4">CADASTRO PARA RECEBIMENTO DE BOLETINS ELETRÔNICOS</h2>
<br />
<h3>FICHA DE CADASTRO</h3> <p> </p> <form name="frmInscricao" id="frmInscricao" method="post" action="" onsubmit="return valida_formulario()"> <fieldset> <p><strong><span class="obrigatorio">*</span> Campos obrigatórios</strong></p> <label for="txtNome">Nome completo<span class="obrigatorio">*</span>:</label> <input type="text" name="txtNome" id="txtNome" size="50" /> <br /> <label for="txtEmail">E-mail <span class="obrigatorio">*</span>:</label> <input type="text" name="txtEmail" id="txtEmail" size="50" /> <br> <div align="center"> <input type="submit" name="btnInscrever" id="btnInscrever" value="Cadastrar-se" class="button" /> </div> </fieldset> </form> </div> <!--fecha a div "cont_esq"-->
<?php //inclui o template do menu da direita include("menu_direita.php");
//inclui o template de rodapé include("rodape.php"); ?>
|