Jump to content


barizon

Member Since 16/07/2010
Offline Last Active 24/01/2011, 16:46
-----

Posts I've Made

In Topic: Envio Não Reconhece Iso-8859-1

24/01/2011, 13:43

Estou enviando dados por um formulário mas não reconhece acentos

No header tenho:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pt" lang="pt-br">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="Content-Language" content="pt-br" />
<head ('Content-type: text/html; charset=ISO-8859-1')>


No php

<?php

$headers= "MIME-Version: 1.0\r\n";
$headers= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers= "Content-Class: urn:content-classes:message\n";

$nome = $_POST["nome"];
$email = $_POST["email"];
$objetivo = $_POST["objetivo"];
$objetivo=preg_replace("/(\015\012)|(\015)|(\012)/","&nbsp;<br />", $objetivo);if($nome=="" || $email=="" || $objetivo=="" ){
$errors=1;
$error.="";
}
if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$email)){
$error.="";
$errors=1;
}
if($errors==1) echo $error;
else{
$where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/"));
$userip = ($_SERVER['X_FORWARDED_FOR']) ? $_SERVER['X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];
$message= utf8_decode($message);
$message="Nome: ".$nome."
E-mail: ".$email."
Objetivo: ".$objetivo."
";
$message = stripslashes($message);
mail("meu@site.com.br","Agendar ",$message," ");
?><?php
}
?>

ao receber os dados o que tem acento vem com interrogalça


Já passei por este problema, você deve ter criado seu banco como UTF-8 o que é mais utilizado atualmente e da conflito com o iso-8859-1, faça assim:

no html:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

no php:
<?php

ini_set('default_charset','UTF-8');

?>

Espero ter ajudado!

In Topic: Ajuda Com Formulario 2

23/01/2011, 13:56

Bom com como vc se atrabalhou todo... :o

vou falar o jeito facil.... :click:

o form.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">
function eStatus(Status){
	if(Status == 0){
		document.getElementById("tf_agendamento_paciente_matricula").style.display ='none';
		document.getElementById("tf_agendamento_paciente_num_guia").style.display ='none';
	}else{
		document.getElementById("tf_agendamento_paciente_matricula").style.display ='block';
		document.getElementById("tf_agendamento_paciente_num_guia").style.display ='block';
	}
}
function abre_conv(){
    window.open('form_busca_conv.php', 'fornruq1w2w', 'top=110, left=110, width=480, height=395');
}
</script>
<title>Untitled Document</title>
</head>
<body>
<form id="todoform" name="todoform" method="post" action="banco/agenda_paciente.php" onsubmit="return validaAgenda()">
<table width="776" border="0" cellspacing="4" cellpadding="0">
<tr>
    <td> </td>
    <td colspan="2">
	 	Convênio: ID 
	 	<input type="text" name="hf_agendamento_paciente_convenio" id="hf_agendamento_paciente_convenio" value=""/>
	 </td>    
    <td>Matrícula:</td>
    <td>Nro Guia:</td>
  </tr>
  <tr>
    <td> </td>
    <td colspan="2">
	 <input name="tf_agendamento_paciente_convenio" type="text" id="tf_agendamento_paciente_convenio" size="60"/>    
	 <input type="button" name="button2" id="button2" value="..." onclick="abre_conv()"/></td>
    <td><input name="tf_agendamento_paciente_matricula" type="text" id="tf_agendamento_paciente_matricula" size="20" /></td>
    <td><input name="tf_agendamento_paciente_num_guia" type="text" id="tf_agendamento_paciente_num_guia" size="20" /></td>
  </tr>
  </table>
</form>  
</body>
</html>

a busca convenio
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script>
function selecionar(ID, NOME, STATUS){

	 window.opener.document.getElementById("tf_agendamento_paciente_convenio").value = NOME;
    window.opener.document.getElementById("hf_agendamento_paciente_convenio").value = ID; 
	 window.opener.eStatus(STATUS);
	 window.close();
	 
/*
  var perfil;
  perfil = document.form1.rg_con.value;
  for(var i=0;i<document.form1.rg_con.length;i++){
          if(document.form1.rg_con[i].checked){
                 perfil = document.form1.rg_con[i].value;
                 break;
          }             
  }
  if(perfil){
          var partes = perfil.split('|');
          window.opener.document.getElementById("tf_agendamento_paciente_convenio").value = partes[0];
          window.opener.document.getElementById("hf_agendamento_paciente_convenio").value = partes[1]; 
          window.close();
  }else{
          alert("Selecione um convenio.");
  }
  */
}
</script>
</head>
<body>
<input type="radio" name="rg_con" value="" onclick="selecionar(1,'Nome 1',1);" /> Nome 1 - status 1
<br />
<input type="radio" name="rg_con" value="" onclick="selecionar(2,'Nome 2',0);" /> Nome 2 - status 0
</body>
</html>

mais facil impossivel.... :boxing:


Perfect!!!.... :D

Tenho mais algumas dúvidas, vc pode me ajudar? :unsure: .....quero que o campo matrícula use a máscara que tb está no banco de dados......ja tenho um script padrão de máscara.....no banco fica salvo (como por exemplo uma máscara) ###.###.##. onde no campo ficaria com essa formatação por exemplo 192.876.92...seria formatado dessa maneira

Cara vc já me ajudou muito...obrigado!!!

In Topic: Ajuda Com Formulario 2

21/01/2011, 16:05

Véio............

:ponder:

vamos pensar um pouco;;;

/* Na Pagina PAI
precisa chamar a Lib jQuery */

$(document).ready(function(){

$("#hf_agendamento_paciente_convenio").each(function(){ //setar o hidden
$.getJSON("caminho/get_convenio.php",{
var_get_convenio: $('#hf_agendamento_paciente_convenio').val()},

function(json){
//0 = nao exige || 1 = exige
if( json.flStatus == 0){
document.getElementById("Id_campo_matricula").disabled=true;
document.getElementById("id_campo_numero_guia").disabled=true;
}

});

});

});


>>> get_convenio.php

<?php
include "../banco/conecta.php";

if(isset($_GET['var_get_convenio']) !=''){

$sqlString = $_GET['var_get_convenio'];

$query = "SELECT campo_0_ou_1 FROM tabel_convenio WHERE id = $sqlString";
$result = mysql_query($query);
$registro = mysql_fetch_array($result);

$json = '{"flStatus":"'.$registro['campo_0_ou_1'].'"}';

echo json_decode($json);

}


?>

Bom tenta ai.


Não deu certo, ve se eu fiz certo por favor:


form_agendamento.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){

$("#hf_agendamento_paciente_convenio").each(function(){ //setar o hidden
$.getJSON("functions/jason.php",{
var_get_convenio: $('#hf_agendamento_paciente_convenio').val()},

function(json){
//0 = nao exige || 1 = exige
if( json.flStatus == 0){
document.getElementById("tf_agendamento_paciente_matricula").disabled=true;
document.getElementById("tf_agendamento_paciente_num_guia").disabled=true;
}
});

});

});
</script>
<script type="text/javascript">
function abre_conv(){
        window.open('form_busca_conv.php', 'fornruq1w2w', 'top=110, left=110, width=480, height=395');
}
</script>
<title>Untitled Document</title>
</head>
<body>
<form id="todoform" name="todoform" method="post" action="banco/agenda_paciente.php" onSubmit="return validaAgenda()">
<table width="776" border="0" cellspacing="4" cellpadding="0">
<tr>
    <td> </td>
    <td colspan="2">Convênio:<input type="hidden" name="hf_agendamento_paciente_convenio" id="hf_agendamento_paciente_convenio"/></td>    
    <td>Matrícula:</td>
    <td>Nro Guia:</td>
  </tr>
  <tr>
    <td> </td>
    <td colspan="2"><input name="tf_agendamento_paciente_convenio" type="text" id="tf_agendamento_paciente_convenio" size="60"/>    <input type="button" name="button2" id="button2" value="..." onclick="abre_conv()"/></td>
    <td><input name="tf_agendamento_paciente_matricula" type="text" id="tf_agendamento_paciente_matricula" size="20" /></td>
    <td><input name="tf_agendamento_paciente_num_guia" type="text" id="tf_agendamento_paciente_num_guia" size="20" /></td>
  </tr>
  </table>
</form>  
</body>
</html>

jason.php
<?php
include "../banco/conecta.php";

if(isset($_GET['var_get_convenio']) !=''){

$sqlString = $_GET['var_get_convenio'];

$query = "SELECT convenio_matricula FROM glo_convenios WHERE convenio_id = $sqlString";
$result = pg_query($conexao,$sql);
$registro = pg_fetch_array($result);

$json = '{"flStatus":"'.$registro['convenio_matricula'].'"}'; 

echo json_decode($json);

}
?>

Obrigado!

In Topic: Ajuda Com Formulário

21/01/2011, 09:03

vejamos....

Se eu entendi... voce pode passar por ajax.

post mais detalhes.


Obrigado pela ajuda Leonardo, postei o código todo no outro tópico que havia criado "Ajuda com Formulario 2". Se você puder dar uma olhada te agradeceria muito!

Abraço.

In Topic: Ajuda Com Formulario 2

21/01/2011, 08:58


Boa tarde galera,

Tem alguma maneira de eu pegar o valor de um campo hidden e atribuir a uma variavel sem eu ter executado o formulario?.

Alguem pode me ajudar?


Acho que não, pois se você não enviar as informações como que ele vai conseguir elas? Mais pra que você quer mesmo fazer isso? Me explique melhor, talvez eu possa lhe ajudar.

Abraços,
bigCheat.


Em primeiro lugar obrigado pela disposição de ajudar!, seguinte tenho um form e nele tenho um campo convenio ao lado do campo tem um botão que quando clicado abre um poup-up com a listagem de todos os convenios cadastrados o usuario escolhe, e o nome e id do convenio escolhido vão para os campos text-field e hidden respectivamente do form pai, quero pegar o valor do campo hidden na hora que o usuario escolhe o convenio desejado para com o id poder saber se o convenio exige o campo matricula e num. de guia e assim deixar os campos habilitados ou não.

form.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">
function abre_conv(){
	window.open('form_busca_conv.php', 'fornruq1w2w', 'top=110, left=110, width=480, height=395');
}
</script>
<title>Untitled Document</title>
</head>

<body>
<table width="776" border="0" cellspacing="4" cellpadding="0">
<tr>
    <td>&nbsp;</td>
    <td colspan="2">Convênio:<input type="hidden" name="hf_agendamento_paciente_convenio" id="hf_agendamento_paciente_convenio"/></td>    
    <td>Matrícula:</td>
    <td>Nro Guia:</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td colspan="2"><input name="tf_agendamento_paciente_convenio" type="text" id="tf_agendamento_paciente_convenio" size="60"/><input type="button" name="button2" id="button2" value="..." onclick="abre_conv()"/></td>
    <td><input name="tf_agendamento_paciente_matricula" type="text" id="tf_agendamento_paciente_matricula" size="20" /></td>
    <td><input name="tf_agendamento_paciente_num_guia" type="text" id="tf_agendamento_paciente_num_guia" size="20" /></td>
  </tr>
  </table>
</body>
</html>

form_busca_conv.php:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>..::Radiologyx&gt;&gt;Agendamento&gt;&gt;Cadastro&gt;&gt;Convênios::..</title>
<link href="../css/ris.css" rel="stylesheet" type="text/css" />
<script language="javascript" type="text/javascript" src="../js/convenio.js"></script>
<style type="text/css">
td div { 
height:150px; 
width:467px;
overflow:auto; 
}
</style>
</head>
<body>
<table width="450" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td valign="top"><img src="../images/interface/lista_conv.gif" width="467" height="20" /></td>
  </tr>
  <tr>
    <td valign="top"><form id="form1" name="form1" method="post" action="form_busca_conv.php">
      <table width="450" border="0" id="todoform" cellspacing="0" cellpadding="0">
        <tr>
          <td width="9" valign="top">&nbsp;</td>
          <td width="432" valign="top">&nbsp;</td>
          <td width="9" valign="top">&nbsp;</td>
        </tr>
        <tr>
          <td colspan="2" valign="top">Nome:</td>
          <td width="9" valign="top">&nbsp;</td>
        </tr>
        <tr>
          <td colspan="3" valign="top"><input name="tf_nome" type="text" id="tf_nome" size="40" maxlength="50" /></td>
        </tr>
        <tr>
          <td valign="top">&nbsp;</td>
          <td valign="top">&nbsp;</td>
          <td valign="top">&nbsp;</td>
        </tr>
        <tr>
          <td colspan="3" valign="top">
          <table width="435" border="0" align="left" cellpadding="0" cellspacing="2">
            <tr>
              <td width="141" valign="top"><input type=image src="../images/interface/botao_busca.gif" width="130" height="50"></td>
              <td width="288" valign="top"><img src="../images/interface/botao_cancela.gif" width="130" height="50" border="0" onclick="window.close();"/></td>
            </tr>
          </table>
          </td>
          </tr>
        <tr>
          <td colspan="3" valign="top">&nbsp;</td>
          </tr>
        <tr>
          <td colspan="3" valign="top">
          <?
		     echo "<table width=\"450\" border=0 cellpadding=\"0\" class=\"titulo_negrito\" cellspacing=\"4\">
			 <tr>
			 <td width=\"350\" align=\"left\">Nome:</td>	
			 <td width=\"100\" align=\"left\"></td>							                
			 </td>
			 </tr>
			 </table>";			  
		  ?>          
          <div>
            <?
			     include "../banco/conecta.php";				 
				 
				 if(isset($_POST['tf_nome']))
				 {
				   $nome = trim(strtoupper($_POST['tf_nome']));
				   $sql = "SELECT convenio_nome, convenio_id FROM glo_convenios where convenio_nome like '$nome%' and convenio_status='1' order by convenio_nome ASC";
				   $result = pg_query($conexao,$sql);
				   $i = 1;					
					 
				   while ($show = pg_fetch_object($result))
				   {
					 $nome = $show->convenio_nome;					
					 $id = $show->convenio_id;					 
					 $i++;
					
					 if(($i%2)!=0){					  				   				  				   
					 echo "<table width=\"450\" border=0 cellpadding=\"0\" class=\"texto\" cellspacing=\"4\">
					 <tr>	
					 <td width=\"350\" align=\"left\"><input type=\"radio\" name=\"rg_con\" value=\"$nome|$id\">$nome</td>		 
				     <td width=\"100\" align=\"left\"></td>
					 </tr>
					 </table>";}
					 
					 else{
					 echo "<table width=\"450\" bgcolor=\"#D6D6D6\" border=0 cellpadding=\"0\" class=\"texto\" cellspacing=\"4\">
					 <tr>
					 <td width=\"350\" align=\"left\"><input type=\"radio\" name=\"rg_con\" value=\"$nome|$id\">$nome</td>		 
				     <td width=\"100\" align=\"left\"></td>
					 </tr>
					 </table>";} 					   
				   }				 
				   pg_close($conexao);					 
				 }
				 
				 else
				 {				
				   $sql = "SELECT convenio_nome, convenio_id FROM glo_convenios where convenio_status='1' order by convenio_nome ASC";
				   $result = pg_query($conexao,$sql);
				   $i = 1;
					 
				   while ($show = pg_fetch_object($result))
				   {
					 $nome = $show->convenio_nome;					
					 $id = $show->convenio_id;					 
					 $i++;
					
					 if(($i%2)!=0){					  				   				  				   
					 echo "<table width=\"450\" border=0 cellpadding=\"0\" class=\"texto\" cellspacing=\"4\">
					 <tr>					
					 <td width=\"350\" align=\"left\"><input type=\"radio\" name=\"rg_con\" value=\"$nome|$id\">$nome</td>		 
				     <td width=\"100\" align=\"left\"></td>
					 </tr>
					 </table>";}
					 
					 else{
					 echo "<table width=\"450\" bgcolor=\"#D6D6D6\" border=0 cellpadding=\"0\" class=\"texto\" cellspacing=\"4\">
					 <tr>
					<td width=\"350\" align=\"left\"><input type=\"radio\" name=\"rg_con\" value=\"$nome|$id\">$nome</td>		 
				     <td width=\"100\" align=\"left\"></td>
					 </tr>
					 </table>";} 					   
				   }				 
				   pg_close($conexao);
				}
               ?>    
          </div></td>
          </tr>
        <tr>
          <td valign="top">&nbsp;</td>
          <td valign="top">&nbsp;</td>
          <td valign="top">&nbsp;</td>
        </tr>
        <tr>
          <td valign="top">&nbsp;</td>
          <td valign="top"><table width="432" border="0" cellspacing="0" cellpadding="0">
            <tr>
         <td align="center"><img src="../images/interface/botao_seleciona.gif" onclick="selecionar()" width="130" height="50" /></td>
         <td align="center"><img src="../images/interface/botao_inclui.gif" onclick="adicionar()" width="130" height="50" /></td>
         <td align="center"><img src="../images/interface/botao_edita.gif" onclick="editar()" width="130" height="50" /></td>
            </tr>
          </table></td>
          <td valign="top">&nbsp;</td>
          </tr>
      </table>
    </form></td>
  </tr>
</table>
</body>
</html>


convenio.js:
function selecionar(){
  var perfil;
  perfil = document.form1.rg_con.value;
  for(var i=0;i<document.form1.rg_con.length;i++){
	  if(document.form1.rg_con[i].checked){
		 perfil = document.form1.rg_con[i].value;
		 break;
	  }		
  }
  if(perfil){
	  var partes = perfil.split('|');
	  window.opener.document.getElementById("tf_agendamento_paciente_convenio").value = partes[0];
	  window.opener.document.getElementById("hf_agendamento_paciente_convenio").value = partes[1]; 
	  window.close();
  }else{
	  alert("Selecione um convenio.");
  }
}
function editar(){
  var perfil;
  perfil = document.form1.rg_con.value;
  for(var i=0;i<document.form1.rg_con.length;i++){
	  if(document.form1.rg_con[i].checked){
		 perfil = document.form1.rg_con[i].value;
		 break;
	  }		
  }
  if(perfil){
	  var partes = perfil.split('|');
	  window.open('form_edita_conv.php?id=' + partes[1], 'Teste44', 'top=110, left=110, width=473, height=335');
	  window.close();
  }else{
	  alert("Selecione um convenio.");
  }
}
function adicionar(){
	window.open('form_add_conv.php', 'scisdade1', 'top=110, left=110, width=473, height=335'); 
	 window.close();
}

Desculpe se coloquei muita coisa, mas achei que fosse a melhor maneira de vc entender o meu problema, obrigado por enquanto!

IPB Skin By Virteq