
Carlos Rocha
Membros-
Total de itens
1.302 -
Registro em
-
Última visita
Tudo que Carlos Rocha postou
-
Converti para UTF-8 (sem DOM) usando o Notepad ++ e esta funcionado. Porem agora apresentou outro erro: Fatal error: main() [<a href='function.main'>function.main</a>]: The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "TCarrinho" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide a __autoload() function to load the class definition in /home/nature/public_html/novo/carrinho_conteudo.php on line 26 Isso quando chamo a classe de carriho de compras abaixo: <?php /* Classe TCarrinho */ class TCarrinho { var $item_codigo = array(); var $item_quantidade = array(); /* ObtemPosicao Este metodo obtem a posicao de um item mediante ao seu codigo, retornando um valor booleano e gravando a posicao na variavel de referencia $posicao, caso o codigo do item esteja no carrinho. */ function ObtemPosicao($codigo,&$posicao){ //Percorrendo o vetor for($i=0;$i<count($this->item_codigo);$i++) { if ($this->item_codigo[$i] == $codigo) { $posicao = $i; return TRUE; } } }/* ObtemPosicao() */ /* ObtemPosicao Este metodo obtem o preço por unidade do produto tendo em mãos o codigo dele. */ function ObtemPreco($codigo){ $Sql = mysql_query("select preço from produtos where id = $codigo"); list($preco_uni) = mysql_fetch_row($Sql); return $preco_uni; //return mysql_result($sql,0,0); }/* ObtemPreco() * /* AdicinarItem Este metodo adiciona um item no carrinho */ function AdicionarItem($codigo,$quantidade) { //Inicializando parametro $posicao = -1; $achou = $this->ObtemPosicao($codigo,$posicao); if (!$achou){ $this->item_codigo[] = $codigo; $this->item_quantidade[] = $quantidade; } } /* AdicionarItem() */ /* RemoverItem Este metodo remove um item do carrinho de compra, passando o codigo do produto */ function RemoverItem($codigo) { //Inicializando parametro $posicao = -1; $achou = $this->ObtemPosicao($codigo,$posicao); if ($achou){ //Removendo o elemento do vetor array_splice($this->item_codigo, $posicao, 1); array_splice($this->item_quantidade, $posicao, 1); } } /* RemoveItem() */ /* QuantosItens Este metodo retorna a quantidade de itens incluidas no carrinho de compras */ function QuantosItens() { return count($this->item_quantidade); } /* QuantosItens() */ /* ExcluirTodosItens Este metodo retira todos os itens contidos no carrinho de compras */ function ExcluirTodosItens(){ $this->item_quantidade = null; $this->item_codigo = null; } /* ExcluirTodosItens() */ /* QuerySQL_ObtemListaDeItens Este metodo gera uma parte do codigo SQL que sera usado para buscar os dados do carrinho de compra (id, NOME e PREÇO). O comando SQL final tera como finalidade de buscar no banco de dados apenas os dados dos itens incluidos no carrinho. */ function QuerySQL_ObtemListaDeItens(){ $itens = "where "; $STR = ""; if ($this->QuantosItens()>0) { $fixo = " id ="; for ($i=0;$i<$this->QuantosItens();$i++){ $STR = $STR . $fixo . " " . $this->item_codigo[$i]; if ($i+1<$this->QuantosItens()) { $STR = $STR . " or "; } } } if (!$STR == "") { return $itens . $STR; }else{ //Caso não exista nenhum item no carrinho o codigo final SQL, procurara por um item que não existe na tabela de produtos, neste caso -1. return "where id = -1"; } } /* QuerySQL_ObtemListaDeItens() */ /* ObtemQuantidadeItem Este metodo obtem a quantidade de um Item */ function ObtemQuantidadeItem($codigo){ $posicao = -1; $achou = $this->ObtemPosicao($codigo,$posicao); if ($achou) { return $this->item_quantidade[$posicao]; }else{ return "erro ao obter quantidade do item"; } } /* ObtemQuantidaItem() */ /* ObtemSubTotalDeUmItem Este metodo retorna o subtotal de um item (QUANTIDADE * VALOR UNITARIO) */ function ObtemSubTotalDeUmItem($id,$preço){ $posicao = -1; $achou = $this->ObtemPosicao($id,$posicao); if ($achou) { return ($this->item_quantidade[$posicao]*$preço); }else{ return "erro ao obter sub total do item"; } } /* ObtemSubTotalDeUmItem() */ /* AtualizarCarrinho Este metodo coleta todos as variaveis enviadas pelo FORMULARO (method="POST") e atualiza as quantidades dos itens. */ function AtualizarCarrinho(&$VAR_ENVIADAS_PELO_BROWSER){ //Percorrendo a lista de itens e atualizando suas quantidades for ($i=0;$i<$this->QuantosItens();$i++){ $this->item_quantidade[$i] = $VAR_ENVIADAS_PELO_BROWSER[$this->item_codigo[$i]]; } } /* AtualizarCarrinho() */ } /* Classe TCarrinho */ ?> carrinho_conteudo.php <?php //Verificando se a variavel de sessão foi criada if (!session_is_registered("MeuCarrinho")){ session_register("MeuCarrinho"); $MeuCarrinho = new TCarrinho(); } $MySQL = new TMySQL(); $MySQL->connect($host, $db, $user, $pass); if (!empty($op)){ switch ($op) { case "adicionar": if (!empty($id_prod)){ $Query = "select id from produtos where id = $id_prod"; $R_Query = $MySQL->query($Query); if (mysql_num_rows($R_Query)>0){ $MeuCarrinho->AdicionarItem($id_prod,1); } } break; case "excluir": $MeuCarrinho->RemoverItem($id_prod); break; case "atualizar": $MeuCarrinho->AtualizarCarrinho($_POST); break; case "finalizar": if ($MeuCarrinho->QuantosItens()>0) { echo "<script>document.location='CarrinhoFinal.php?acao=qual_cep&preco_total=$preco_total&peso_medio=$peso_medio'</script>"; } break; } } if ($MeuCarrinho->QuantosItens()==0) { echo "<table align='center'>"; echo "</tr><td>"; echo " <p><p><h2>Carrinho Vazio</h2><p><p>"; echo "</tdf></tr>"; echo "</table>"; } else { $QuerySQL = "select id, nome, preço, peso from produtos " . $MeuCarrinho->QuerySQL_ObtemListaDeItens(); $Resultado = $MySQL->query($QuerySQL); ?> <table BORDER=0 CELLSPACING=0 CELLPADDING=0 COLS=1 WIDTH="100%" BGCOLOR="#0080C0" > <tr> <td> <center><b><font color="#FFFFFF">Minha Loja - Carrinho</font></b></center> </td> </tr> </table> <form method="POST" action="carrinho.php?op=atualizar"> <table BORDER=0 CELLSPACING=2 CELLPADDING=4 COLS=5 WIDTH="100%"> <tr BGCOLOR="#004080"> <td> <center><b><font color="#FFFF99">ITEM</font></b></center> </td> <td> <center><b><font color="#FFFF99">QTD.</font></b></center> </td> <td> <center><b><font color="#FFFF99">PREÇO UNITÁRIO</font></b></center> </td> <td bgcolor="#004080"> <center><b><font color="#FFFF99">TOTAL</font></b></center> </td> <td BGCOLOR="#004080"></td> </tr> <? $preco_total = 0.00; $peso_medio = 0.00; while(list($id, $nome, $preço, $peso) = mysql_fetch_row($Resultado)) { //Computando preço total $preco_total = $preco_total + $MeuCarrinho->ObtemSubTotalDeUmItem($id,$preço); $peso_medio = $peso_medio + $MeuCarrinho->ObtemSubTotalDeUmItem($id,$peso); session_register("preco_total"); session_register("peso_medio"); echo " <tr> <td><font size=-1>". $nome ."</font></td> <td> <center><input type=TEXT name=". $id ." size=2 value=". $MeuCarrinho->ObtemQuantidadeItem($id) ."></center> </td> <td> <center><b>". number_format($preço, 2, '.', '')."</b></center> </td> <td> <center><b>". number_format($MeuCarrinho->ObtemSubTotalDeUmItem($id,$preço), 2, '.', '') ."</b></center> </td> <td><b><font face=Tahoma><font size=-2><a href=carrinho.php?op=excluir&id_prod=". $id .">Excluir</a></font></font></b></td> </tr> "; } ?> <tr> <td></td> <td><b><font color="#FF0000"></font></b> </td> <td> <div align=right><b><font color="#FF0000">TOTAL(R$)</font></b></div> </td> <td BGCOLOR="#FFFFD7"> <center><b><font color="#990000"><?=number_format($preco_total, 2, '.', ''); ?></font></b></center> </td> <td></td> </tr> </table> <center><input type="submit" value="Atualizar" name="Atualizar" WIDTH="78" HEIGHT="20" style="background-color: rgb(0,111,55); color: rgb(255,255,0)"><center><br> </form> <TABLE> <TR> <TD> <form method="post" action="produtos.php?acao=listar"> <center><input type="submit" value="<< Voltar as Compras" name="Atualizar" WIDTH="78" HEIGHT="20" style="background-color: rgb(0,111,55); color: rgb(255,255,0)"><center> </form> </TD> <TD> <form method="post" action="carrinho.php?op=finalizar"> <input type="hidden" name="preco_total" value="<?=number_format($preco_total, 2, '.', ''); ?>"> <input type="hidden" name="peso_medio" value="<?=number_format($peso_medio, 2, '.', ''); ?>"> <center><input type="submit" value="Finalizar Compra >>" name="Atualizar" WIDTH="78" HEIGHT="20" style="background-color: rgb(0,111,55); color: rgb(255,255,0)"><center> </form> </TD> </TR> </TABLE> <? } ?> Esta iclusive destruindo as sessions. O que faço agora?
-
2 perguntas: 1) "tira o BOM dos arquivos". Como? 2) "A menos que o servidor seja dedicado" E se for? Como faz?
-
Mas a minha duvida é a seguinte: Se localmente (aqui no meu PC), o erro com as sessions não acontece e, la no servidor (hospedagem )acontece. Dai chego a conclusão que é alguma configuração do php.ini para o DOM. Mas qual?
-
Resolvi o problema dos acentos abrindo todos os arquivos no bloco de notas e usando o "salvar como" trocando Ansi por utt-8. Agora, SOMENTE NO SERVIDOR WEN POIS AQUI NO LOCALHOST NÃO DA O ERRO, esta acontecendo erro de cabeçalho e seession. Quando abro as páginas, da o seguinte erro: Warning: Cannot modify header information - headers already sent by (output started at /home/nature/public_html/novo/index.php:1) in /home/nature/public_html/novo/index.php on line 2 Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/nature/public_html/novo/index.php:1) in /home/nature/public_html/novo/index.php on line 5 Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/nature/public_html/novo/index.php:1) in /home/nature/public_html/novo/index.php on line 5 Na linha 5 do index.php tem: ... session_start(); ... como resolver isso? Detalhe: Esse erro só da quando rodo a pagina no seridor web. Localmente (localhost) não dá esse erro. Acompanhe: http://naturelavie.com.br/novo/
-
Sabe irmão. Pense comigo. Eu uso o dreamweavber. Já estou acostumado com ele.; Conheço o NetBeans pois trocar a IDE é o meso que trocar de noiva. Eu não sou um exime programado aind. Por isso, estou te pedindo ajuda. Mas, vejo o problema vindo do include.; Deve ter uma configurasção no php.ini para isso. Os dadsos que vem do banco,. chegam normal pois a conexão com, o MySql esta codificada utf-8 o html tambem esta e o php Mas, só os textos veem assim
-
Como assim duvida Pensa bem: eu uso o dreamweaver parta criar todas as paginmas que uso.; tem a pagins chamadora e a chamada. com,o o dw salvará a chamada em utf8 e a chamada em iso
-
Todos os arquivos forma feitos a patir do Dreweaver, e como você pode ver no codigo acima, o arquivo incuido só tem isso: <?php $bairro="São Francisco"; $ip = getenv("REMOTE_ADDR"); print $bairro; print "<br>"; print "São Francisco e você"; print "<br>"; ?> Ou seja, para teste só exibição de variaveis php normal. Esta me parecendo um problema de cofiguração do php.ini nos includes
-
Mas hein Sergio, essa parte eu já havia entendido. Uso: DW CS4 (SALVA UTF8) APACHE 2.2.14 PHP 5.3.1 MYSQL 6 O PROBLEMA SÓ DA QUANDO O CÓDIGO, TEXTO, ETC.. ESTIVER NUMA PAGINA CHAMADA POR INCLUDE. SE, EXECUTAR O MESMO SCRIPT NA PAGINA CHAMADORA, O SCRIPT RODA COM OS ACENTOS CERTINHO. O QUE FAZER NESSE CASO
-
Bom, uma coisa descobrí: Tudo que vem por include, o cabeçalho header('Content-Type: text/html; charset=utf-8'); não decodifica. O que é escrito direto na pagina, ai sim ele decodifica. Mas, com,o resolver isso?
-
Ola pessoal. Estou com um problema que esta me tirando o sono! seguinte: Tenho a pagina abaixo que chama outras. Acontece que, quando coloco esse script dentro da pagina cadastro_conteudo.php ai ele da erro de script. <? header('Content-Type: text/html; charset=utf-8'); include ("global/funcoes_php/var.php"); include ("global/funcoes_php/conecta.php"); session_start(); ?> <html> <head> <title><?php echo $title; ?></title> <? include ("global/funcoes_php/campos_meta.php")?> <link href="global/stilo.css" rel="stylesheet" type="text/css"> <script language="JavaScript" src="global/validacoes_java_script/valida_cadastro.js"></script> <script language="JavaScript" src="global/funcoes_java_script/mascara.js"></script> <script language="JavaScript" src="global/funcoes_java_script/abre_fecha.js"></script> </head> <body> <table bgcolor="#008B43" width="1000" border="0" cellspacing="0" cellpadding="0" align="center"> <tr> <td align="center" ><? include("global/topo.php"); ?></td> </tr> <tr> <td valign="top" ><? include("cadastro_conteudo.php");?></td> </tr> <tr> <td align="center" ><? include("global/base.php"); ?></td> </tr> </table> </body> </html> Desse jeito rerorna assim: S�o Francisco S�o Francisco e voc� Mas quando, no lugar do include para a pagina cadastro_conteudo.php, rodo um script que tenho, ele roda normal. assim: <? header('Content-Type: text/html; charset=utf-8'); include ("global/funcoes_php/var.php"); include ("global/funcoes_php/conecta.php"); session_start(); ?> <html> <head> <title><?php echo $title; ?></title> <? include ("global/funcoes_php/campos_meta.php")?> <link href="global/stilo.css" rel="stylesheet" type="text/css"> <script language="JavaScript" src="global/validacoes_java_script/valida_cadastro.js"></script> <script language="JavaScript" src="global/funcoes_java_script/mascara.js"></script> <script language="JavaScript" src="global/funcoes_java_script/abre_fecha.js"></script> </head> <body> <table bgcolor="#008B43" width="1000" border="0" cellspacing="0" cellpadding="0" align="center"> <tr> <td align="center" ><? include("global/topo.php"); ?></td> </tr> <tr> <td valign="top" > <?php $bairro="São Francisco"; $ip = getenv("REMOTE_ADDR"); print $bairro; print "<br>"; print "São Francisco e você"; print "<br>"; ?> </td> </tr> <tr> <td align="center" ><? include("global/base.php"); ?></td> </tr> </table> </body> </html> Mas desse jeito rerorna assim: São Francisco São Francisco e você Isso não esta tendo lógica mas esta acontecendo. Grato a quem puder ajudar.
-
utf8 - Diferença entre localhost e servidor remoto
pergunta respondeu ao Carlos Rocha de Carlos Rocha em PHP
Gente. Tudo começo assim: Um form de cadastro de clientes que joga no Mysql assim: <? if ($acao=="cad") { $email = $_POST['email']; $senha = $_POST['senha']; $nome = ucwords($_POST['nome']); $endereco = $_POST['endereco']; $numero = $_POST['numero']; $bairro = $_POST['bairro']; $cep = $_POST['cep']; $cidade = $_POST['cidade']; $estado = $_POST['estado']; $tel = $_POST['tel']; $cel = $_POST['cel']; if($link){ $busca = mysql_query("SELECT nome FROM clientes where nome='$nome';") or die("A consulta falhou: " . mysql_error()); if(mysql_num_rows($busca) > 0){echo "Ola $nome, voce já cadastrou o teu e-mail";} else { $sql = "INSERT INTO clientes(email, senha, cpfcnpj, nome, endereco, numero, bairro, cep, cidade, estado, tel, cel,Bloqueio) VALUES('$email', '$senha', '$cpfcnpj', '$nome', '$endereco', '$numero', '$bairro', '$cep', '$cidade', '$estado', '$tel', '$cel','N')"; if(mysql_query($sql, $link)){ $texto = " Olá $nome! Obrigado por ter se cadastrado conosco, e por favor nos ajude a divulgar o nosso trabalho. Agora, você receberá em primeira mão as novidades do nosso site nosso site. "; $nome_cadastro = split(" ",$nome); $mail = mail("$email", "Boas vindas ao nosso site","$texto","From: naturelavie@gmail.com\nDate: $date\n"); echo $texto; } else { echo("<H1>Olá $nome: não foi possivel realizar o Teu cadastro por favor tente novamente...</H1>"); } } echo ("Erro de comunicação com o banco. Por favor tente mais tarde!"); } } ?> Bom, ai, tanto local quanto na web esta gravando o Bairro assim: são Francisco Na hora de exibir os dados do novo cliente é que dá esse erro é que da esse erro -
utf8 - Diferença entre localhost e servidor remoto
pergunta respondeu ao Carlos Rocha de Carlos Rocha em PHP
OH IRMÃO. VALEU A FORÇA MAS CARA NEM SEI QUANTOS SÃO OS ARQUIVOS DO SITE. já IMAGINOU FAZER ISSO UM POR UM? -
utf8 - Diferença entre localhost e servidor remoto
pergunta respondeu ao Carlos Rocha de Carlos Rocha em PHP
Olha só. Fiz o arquivo abaixo assim para teste: <? $bairro="São Francisco"; $bairro2="São Francisco"; $ip = getenv("REMOTE_ADDR"); print $bairro; print "<br>"; print $bairro2; print "<br>"; print utf8_decode("Enddereço IP do computador que você esta usando: "); print $ip; print "<br>"; print "Enddereço IP do computador que você esta usando: ". $ip; print "<br>"; print "São Francisco e você"; ?> Rodando local retornou o seguinte: São Francisco São Francisco Enddere?IP do computador que voc?sta usando: 127.0.0.1 Enddereço IP do computador que você esta usando: 127.0.0.1 São Francisco e você Rodando no servidor hospedagem retornou o seguinte: S�o Francisco São Francisco Enddere?IP do computador que voc?sta usando: 189.83.162.98 Enddere�o IP do computador que voc� esta usando: 189.83.162.98 S�o Francisco e voc Onde será que esta o erro? -
utf8 - Diferença entre localhost e servidor remoto
pergunta respondeu ao Carlos Rocha de Carlos Rocha em PHP
O Collation dos mysql do servidor e do local são utf8_general_ci -
utf8 - Diferença entre localhost e servidor remoto
pergunta respondeu ao Carlos Rocha de Carlos Rocha em PHP
Ok mas no banco MySql tanto do servidor quanto aqui no localhost esta gravado assim: São Francisco Como o php poderia exibir: São Francisco ? Segue my.ini do mysql local # MySQL Server Instance Configuration File # ---------------------------------------------------------------------- # Generated by the MySQL Server Instance Configuration Wizard # # # Installation Instructions # ---------------------------------------------------------------------- # # On Linux you can copy this file to /etc/my.cnf to set global options, # mysql-data-dir/my.cnf to set server-specific options # (@localstatedir@ for this installation) or to # ~/.my.cnf to set user-specific options. # # On Windows you should keep this file in the installation directory # of your server (e.g. C:\Program Files\MySQL\MySQL Server X.Y). To # make sure the server reads the config file use the startup option # "--defaults-file". # # To run run the server from the command line, execute this in a # command line shell, e.g. # mysqld --defaults-file="C:\Program Files\MySQL\MySQL Server X.Y\my.ini" # # To install the server as a Windows service manually, execute this in a # command line shell, e.g. # mysqld --install MySQLXY --defaults-file="C:\Program Files\MySQL\MySQL Server X.Y\my.ini" # # And then execute this in a command line shell to start the server, e.g. # net start MySQLXY # # # Guildlines for editing this file # ---------------------------------------------------------------------- # # In this file, you can use all long options that the program supports. # If you want to know the options a program supports, start the program # with the "--help" option. # # More detailed information about the individual options can also be # found in the manual. # # # CLIENT SECTION # ---------------------------------------------------------------------- # # The following options will be read by MySQL client applications. # Note that only client applications shipped by MySQL are guaranteed # to read this section. If you want your own MySQL client program to # honor these values, you need to specify it as an option during the # MySQL client library initialization. # [client] port=3306 [mysql] default-character-set=utf8 # SERVER SECTION # ---------------------------------------------------------------------- # # The following options will be read by the MySQL Server. Make sure that # you have installed the server correctly (see above) so it reads this # file. # [mysqld] # The TCP/IP Port the MySQL Server will listen on port=3306 #Path to installation directory. All paths are usually resolved relative to this. basedir="C:/Arquivos de programas/Apache Software Foundation/mysql/" #Path to the database root datadir="C:/Arquivos de programas/Apache Software Foundation/mysql/Data/" # The default character set that will be used when a new schema or table is # created and no character set is defined default-character-set=utf8 # The default storage engine that will be used when create new tables when default-storage-engine=INNODB # Set the SQL mode to strict sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION" # The maximum amount of concurrent sessions the MySQL server will # allow. One of these connections will be reserved for a user with # SUPER privileges to allow the administrator to login even if the # connection limit has been reached. max_connections=100 # Query cache is used to cache SELECT results and later return them # without actual executing the same query once again. Having the query # cache enabled may result in significant speed improvements, if your # have a lot of identical queries and rarely changing tables. See the # "Qcache_lowmem_prunes" status variable to check if the current value # is high enough for your load. # Note: In case your tables change very often or if your queries are # textually different every time, the query cache may result in a # slowdown instead of a performance improvement. query_cache_size=0 # The number of open tables for all threads. Increasing this value # increases the number of file descriptors that mysqld requires. # Therefore you have to make sure to set the amount of open files # allowed to at least 4096 in the variable "open-files-limit" in # section [mysqld_safe] table_cache=256 # Maximum size for internal (in-memory) temporary tables. If a table # grows larger than this value, it is automatically converted to disk # based table This limitation is for a single table. There can be many # of them. tmp_table_size=5M # How many threads we should keep in a cache for reuse. When a client # disconnects, the client's threads are put in the cache if there aren't # more than thread_cache_size threads from before. This greatly reduces # the amount of thread creations needed if you have a lot of new # connections. (Normally this doesn't give a notable performance # improvement if you have a good thread implementation.) thread_cache_size=8 #*** MyISAM Specific options # The maximum size of the temporary file MySQL is allowed to use while # recreating the index (during REPAIR, ALTER TABLE or LOAD DATA INFILE. # If the file-size would be bigger than this, the index will be created # through the key cache (which is slower). myisam_max_sort_file_size=100G # If the temporary file used for fast index creation would be bigger # than using the key cache by the amount specified here, then prefer the # key cache method. This is mainly used to force long character keys in # large tables to use the slower key cache method to create the index. myisam_sort_buffer_size=8M # Size of the Key Buffer, used to cache index blocks for MyISAM tables. # Do not set it larger than 30% of your available memory, as some memory # is also required by the OS to cache rows. Even if you're not using # MyISAM tables, you should still set it to 8-64M as it will also be # used for internal temporary disk tables. key_buffer_size=8M # Size of the buffer used for doing full table scans of MyISAM tables. # Allocated per thread, if a full scan is needed. read_buffer_size=64K read_rnd_buffer_size=256K # This buffer is allocated when MySQL needs to rebuild the index in # REPAIR, OPTIMZE, ALTER table statements as well as in LOAD DATA INFILE # into an empty table. It is allocated per thread so be careful with # large settings. sort_buffer_size=212K #*** INNODB Specific options *** # Use this option if you have a MySQL server with InnoDB support enabled # but you do not plan to use it. This will save memory and disk space # and speed up some things. #skip-innodb # Additional memory pool that is used by InnoDB to store metadata # information. If InnoDB requires more memory for this purpose it will # start to allocate it from the OS. As this is fast enough on most # recent operating systems, you normally do not need to change this # value. SHOW INNODB STATUS will display the current amount used. innodb_additional_mem_pool_size=2M # If set to 1, InnoDB will flush (fsync) the transaction logs to the # disk at each commit, which offers full ACID behavior. If you are # willing to compromise this safety, and you are running small # transactions, you may set this to 0 or 2 to reduce disk I/O to the # logs. Value 0 means that the log is only written to the log file and # the log file flushed to disk approximately once per second. Value 2 # means the log is written to the log file at each commit, but the log # file is only flushed to disk approximately once per second. innodb_flush_log_at_trx_commit=1 # The size of the buffer InnoDB uses for buffering log data. As soon as # it is full, InnoDB will have to flush it to disk. As it is flushed # once per second anyway, it does not make sense to have it very large # (even with long transactions). innodb_log_buffer_size=1M # InnoDB, unlike MyISAM, uses a buffer pool to cache both indexes and # row data. The bigger you set this the less disk I/O is needed to # access data in tables. On a dedicated database server you may set this # parameter up to 80% of the machine physical memory size. Do not set it # too large, though, because competition of the physical memory may # cause paging in the operating system. Note that on 32bit systems you # might be limited to 2-3.5G of user level memory per process, so do not # set it too high. innodb_buffer_pool_size=8M # Size of each log file in a log group. You should set the combined size # of log files to about 25%-100% of your buffer pool size to avoid # unneeded buffer pool flush activity on log file overwrite. However, # note that a larger logfile size will increase the time needed for the # recovery process. innodb_log_file_size=10M # Number of threads allowed inside the InnoDB kernel. The optimal value # depends highly on the application, hardware as well as the OS # scheduler properties. A too high value may lead to thread thrashing. innodb_thread_concurrency=8 -
utf8 - Diferença entre localhost e servidor remoto
pergunta respondeu ao Carlos Rocha de Carlos Rocha em PHP
No head das minhas paginas já carrega o charset como utf-8 Mas, você conseguiu entender? Estou carregando o form assim: <TR> <TD>BAIRRO</TD> <TD><INPUT Type='text' NAME='TBAIRRO' value='$bairro'></TD> </TR> No localhost pede para colocar a função utf8 assim: <TR> <TD>BAIRRO</TD> <TD><INPUT Type='text' NAME='TBAIRRO' value='".utf8_decode($bairro)."'></TD> </TR> Mas la no servbidor de hospedagem não pede. Em outras palavras,. não precisa colocar. Tendeu mais ou menos? -
Ola.; Tenho uma duvida com utf8 No meu servidor local (localhost), quando vou exibir uma variael que recebne valor dor banco que contenho um valor como por exemplo o til (São), ele exibe o til como valor assim: (São). Acontece que no meu servidor remoto (internet) ele exibe esse mesmo valor normal. Isso é alguma configuração do php.ini? Qual? Detalhe: no banco esta assim: São Francisco Localhost Exibe : São Francisco Host Hospedagem Exibe : São Francisco utf8 - Diferença entre localhost e servidor remoto No meu php.ini, essa linha default_charset = "iso-8859-1", esta comentada. Tirei o comentario, reiniciei o Apache e não resolveu. E no Arquivo de confirgurações do Apache (httpd.conf)não tem alinha AddDefaultCharset utf-8. Meu php é 5.3.1 Meu Apache é 2.2.14
-
form HTML dentro Variavel php não envia dados
pergunta respondeu ao Carlos Rocha de Carlos Rocha em PHP
Olha só Fiz algumas alterações de (falta de atenção) e resolveu. O problema agora é que eu tenho duas variaveis que estão no arquivo frete.php (são elas $valor_final e $total) que não chegam ao form (que por sua vez é chamado de dentro do frete.php) Eu preciso dentro de form, chamalas assim: <input type='hidden' name='valor_final' value='$valor_final'> <input type='hidden' name='TVALOR_FRETE' value='$total'> Para envialas junto com, o form para o MySql. Como saio dessa? -
Ola a todos! Resolvi em partes meu problema. O que eu fiz: Peguei um formulario e coloquei ele todo dentro de uma variavel $FORMULARIO; Depois dessa variavel, fiz um include para uma pagina (frete.php) que me retornará o resultado do calculo do frete. Eu acho que até não há nehuma novidade né? Acontece, que nessa pagina frete.php, tem uma chamada para a variavel $FORMULARIO pois, caso o resultado do frete.php dê um numero negativo exibe o erro, mas, caso o frete.php retorne valores do frete, dai exibe o formulario que esta na variavel $FORMULARIO; Até ai deu para entender? Bom, até neste ponto, tudo esta correto. Porem, quando submeto os dados do formulario que esta na variavel $FORMULARIO, os $HTTP_POST_VARS simplemente não vão. Eis os códigos: CarrinhoFinal_Conteudo.php ... if ($acao=="RECEBE_CEP_SERVICO") { $busca = mysql_query("SELECT * FROM clientes where id='$SESSAOlogin';") or die("A consulta falhou: " . mysql_error()); list($id, $nome, $email, $cidade, $estado, $senha, $cpfcnpj, $tel, $cel, $endereco, $numero, $bairro,$cep) = mysql_fetch_row($busca); $FORM_ENDERECO = " <FORM METHOD='POST' ACTION='CarrinhoFinal.php?acao=gravar_pedido' name='FORM'> <INPUT TYPE='hidden' NAME='FORM' VALUE='FORM'> <INPUT TYPE='hidden' NAME='peso_medio' VALUE='$peso_medio'> <input type='hidden' name='TENVIO' value='$TENVIO; ?>'> <input type='hidden' name='TCEP' value='$TCEP; ?>'> <input type='hidden' name='Id_Cliente' value='$SESSAOlogin; ?>'> <TABLE width='400' align='center'> <tr><td colspan='2' align='center'><h2><b>Finalizando Compra<br>Por favor. Confira os dados e preencha corretamente o formulário antes de prosseguir!</b></h2></td></tr> <TR> <TD>PAGAMENTO </TD> <TD> <!-- <div id='cartao' style='display:block;'>oi</div> onclick='java script: fecha('cartao');' --> <INPUT type='radio' NAME='TPGTO' value='MASTERCARD' checked='checked'> MASTERCARD <br> <INPUT type='radio' NAME='TPGTO' value='BOLETO'> BOLETO (À Vista)<br> <INPUT type='radio' NAME='TPGTO' value='DEPOSITO'> DEPÓSITO (À Vista) </TD> </TR> <TR> <TD>NOME:/RAZÃO SOCIAL </TD> <TD><INPUT TYPE='text' NAME='TNOME' value='$nome' disabled='disabled'></TD> </TR> <TR> <TD>CPF/CNPJ:</TD> <TD><INPUT TYPE='text' NAME='TCPF' value='$cpfcnpj' disabled='disabled'></TD> </TR> <TR> <TD>EMAIL:</TD> <TD><INPUT TYPE='text' NAME='TEMAIL' value='$email' disabled='disabled'></TD> </TR> <TR> <TD>ENDEREÇO: <font color='red'>(de entrega)</font></TD> <TD><INPUT TYPE='text' NAME='TENDERECO' value='$endereco'></TD> </TR> <TR> <TD>BAIRRO:</TD> <TD><INPUT TYPE='text' NAME='TBAIRRO' value='$bairro'></TD> </TR> <TR> <TD>CIDADE:</TD> <TD><INPUT TYPE='text' NAME='TCIDADE' value='$cidade'></TD> </TR> <TR> <TD>ESTADO:</TD> <TD><INPUT TYPE='text' NAME='TESTADO' value='$estado'></TD> </TR> <TR> <TD>FONE (Contato):</TD> <TD><INPUT TYPE='text' NAME='TFONE' value='$tel'></TD> </TR> <input type='hidden' name='valor_final' value='$valor_final; ?>'> <TR align='center'> <TD colspan='2'><input type='submit' name='Finalizar' value='Finalizar' WIDTH='78' HEIGHT='20' style='background-color: rgb(0,111,55); color: rgb(255,255,0)' onClick='CriticaFormulario()'></TD> </TR> </TABLE> </FORM> "; include ('frete.php'); } } frete.php <?php ##################################### # Código dos Serviços dos Correios # # FRETE PAC = 41106 # # FRETE SEDEX = 40010 # # FRETE SEDEX 10 = 40215 # # FRETE SEDEX HOJE = 40290 # # FRETE E-SEDEX = 81019 # # FRETE MALOTE = 44105 # # FRETE NORMAL = 41017 # # SEDEX A COBRAR = 40045 # ##################################### $nCdEmpresa = ""; $sDsSenha = ""; $nCdServico = $_POST['TENVIO']; $sCepOrigem = 36855000; $sCepDestino = $_POST['TCEP']; $sCepDestino = eregi_replace("([^0-9])","",$sCepDestino); $nVlPeso = $peso_medio; $nCdFormato = 1; $nVlComprimento = 20; $nVlAltura = 20; $nVlLargura = 20; $nVlDiametro = 0; $sCdMaoPropria = "N"; $nVlValorDeclarado = 0; $sCdAvisoRecebimento = "S"; // URL de Consulta dos Correios entregue à variavel $correios $correios ="http://shopping.correios.com.br/wbm/shopping/script/CalcPrecoPrazo.aspx?" ."nCdEmpresa=$nCdEmpresa&" ."sDsSenha=$sDsSenha&" ."sCepOrigem=$sCepOrigem&" ."sCepDestino=$sCepDestino&" ."nVlPeso=$nVlPeso&" ."nCdFormato=$nCdFormato&" ."nVlComprimento=$nVlComprimento&" ."nVlAltura=$nVlAltura&" ."nVlLargura=$nVlLargura&" ."sCdMaoPropria=$sCdMaoPropria&" ."nVlValorDeclarado=$nVlValorDeclarado&" ."sCdAvisoRecebimento=$sCdAvisoRecebimento&" ."nCdServico=$nCdServico&" ."nVlDiametro=$nVlDiametro&" ."StrRetorno=xml"; $dados_correios = simplexml_load_file($correios); //print_r($dados_correios); print "<p>"; $total = $dados_correios->xpath('cServico/Valor'); $total = floatval(str_replace(',', '.', $total[0])); $PrazoEntrega = $dados_correios->xpath('cServico/PrazoEntrega'); $erros = $dados_correios->xpath('cServico/Erro'); $ValorAvisoRecebimento = $dados_correios->xpath('cServico/ValorAvisoRecebimento'); if ($erros[0] != 0) { // Tratamento dos Erros //CEP de destino inválido if ($erros[0] == -3) { Print "CEP de destino inválido.<br> Cloque <a href='java script:window.history.go(-1)'>Aqui</a> e tente um novo CEP!"; echo "<script>document.FORM.Finalizar.disabled=true;</script>"; } //Sistema temporariamente fora do ar. Favor tentar mais tarde. else if ($erros[0] == -33) { Print "Sistema dos correios temporariamente fora do ar.<br> Por favor navegue um pouco mais pelo site e após alguns segundos, tente novamente!"; echo "<script>document.FORM.Finalizar.disabled=true;</script>"; } //Serviço indisponível para o trecho informado. else if ($erros[0] == -6) { echo "<script>alert('Sistema dos correios indisponível para o trecho informado');</script>"; session_unregister("MeuCarrinho"); echo "<script>document.location='produtos.php?acao=listar'</script>"; } //Para qualquer outro erro else { Print "CEP de destino inválido ou erro no sistema dos correios.<br> Cloque <a href='java script:window.history.go(-1)'>Aqui</a> e tente um novo CEP!"; echo "<script>document.FORM.Finalizar.disabled=true;</script>"; } } else { print $FORM_ENDERECO; switch ($nCdServico) { case 41106: $nome_servico = " PAC "; break; case 40010: $nome_servico = " SEDEX "; break; } ?> <TABLE width='400' align='center'><tr> <TD>VALORES:</TD> <TD> <? print "O valor da sua compra sem o frete R$ "; print number_format($preco_total, 2, ',', '.'); print "<p>"; print "O valor do envio por "; print $nome_servico; print " será de: R$"; print number_format($total, 2, ',', '.'); print "<p>"; print "O prazo de entrega será de "; print $PrazoEntrega[0]; print " dia(s) úteis"; print "<p>"; $valor_final = $total + $preco_total; print "O valor da tua compra com o frete R$ "; print number_format($valor_final, 2, ',', '.'); ?> </td></tr></table> <? } // Neste exemplo estou colocando apenas PAC e SEDEX ?>
-
desabiltar um botão submit (ou button) de um formulario
pergunta respondeu ao Carlos Rocha de Carlos Rocha em Ajax, JavaScript, XML, DOM
Ola a todos! Resolvi em partes o problema. O que eu fiz: Peguei um formulario e coloquei ele todo dentro de uma variavel $FORMULARIO; Depois dessa variavel, fiz um include para uma pagina (frete.php) que me retornará o resultado do calculo do frete. Eu acho que até não há nehuma novidade né? Acontece, que nessa pagina frete.php, tem uma chamada para a variavel $FORMULARIO pois, caso o resultado do frete.php dê um numero negativo exibe o erro, mas, caso o frete.php retorne valores do frete, dai exibe o formulario que esta na variavel $FORMULARIO; Até ai deu para entender? Bom, até neste ponto, tudo esta correto. Porem, quando submeto os dados do formulario que esta na variavel $FORMULARIO, os $HTTP_POST_VARS simplemente não vão. Eis os códigos: CarrinhoFinal_Conteudo.php ... if ($acao=="RECEBE_CEP_SERVICO") { $busca = mysql_query("SELECT * FROM clientes where id='$SESSAOlogin';") or die("A consulta falhou: " . mysql_error()); list($id, $nome, $email, $cidade, $estado, $senha, $cpfcnpj, $tel, $cel, $endereco, $numero, $bairro,$cep) = mysql_fetch_row($busca); $FORM_ENDERECO = " <FORM METHOD='POST' ACTION='CarrinhoFinal.php?acao=gravar_pedido' name='FORM'> <INPUT TYPE='hidden' NAME='FORM' VALUE='FORM'> <INPUT TYPE='hidden' NAME='peso_medio' VALUE='$peso_medio'> <input type='hidden' name='TENVIO' value='$TENVIO; ?>'> <input type='hidden' name='TCEP' value='$TCEP; ?>'> <input type='hidden' name='Id_Cliente' value='$SESSAOlogin; ?>'> <TABLE width='400' align='center'> <tr><td colspan='2' align='center'><h2><b>Finalizando Compra<br>Por favor. Confira os dados e preencha corretamente o formulário antes de prosseguir!</b></h2></td></tr> <TR> <TD>PAGAMENTO </TD> <TD> <!-- <div id='cartao' style='display:block;'>oi</div> onclick='java script: fecha('cartao');' --> <INPUT type='radio' NAME='TPGTO' value='MASTERCARD' checked='checked'> MASTERCARD <br> <INPUT type='radio' NAME='TPGTO' value='BOLETO'> BOLETO (À Vista)<br> <INPUT type='radio' NAME='TPGTO' value='DEPOSITO'> DEPÓSITO (À Vista) </TD> </TR> <TR> <TD>NOME:/RAZÃO SOCIAL </TD> <TD><INPUT TYPE='text' NAME='TNOME' value='$nome' disabled='disabled'></TD> </TR> <TR> <TD>CPF/CNPJ:</TD> <TD><INPUT TYPE='text' NAME='TCPF' value='$cpfcnpj' disabled='disabled'></TD> </TR> <TR> <TD>EMAIL:</TD> <TD><INPUT TYPE='text' NAME='TEMAIL' value='$email' disabled='disabled'></TD> </TR> <TR> <TD>ENDEREÇO: <font color='red'>(de entrega)</font></TD> <TD><INPUT TYPE='text' NAME='TENDERECO' value='$endereco'></TD> </TR> <TR> <TD>BAIRRO:</TD> <TD><INPUT TYPE='text' NAME='TBAIRRO' value='$bairro'></TD> </TR> <TR> <TD>CIDADE:</TD> <TD><INPUT TYPE='text' NAME='TCIDADE' value='$cidade'></TD> </TR> <TR> <TD>ESTADO:</TD> <TD><INPUT TYPE='text' NAME='TESTADO' value='$estado'></TD> </TR> <TR> <TD>FONE (Contato):</TD> <TD><INPUT TYPE='text' NAME='TFONE' value='$tel'></TD> </TR> <input type='hidden' name='valor_final' value='$valor_final; ?>'> <TR align='center'> <TD colspan='2'><input type='submit' name='Finalizar' value='Finalizar' WIDTH='78' HEIGHT='20' style='background-color: rgb(0,111,55); color: rgb(255,255,0)' onClick='CriticaFormulario()'></TD> </TR> </TABLE> </FORM> "; include ('frete.php'); } } frete.php <?php ##################################### # Código dos Serviços dos Correios # # FRETE PAC = 41106 # # FRETE SEDEX = 40010 # # FRETE SEDEX 10 = 40215 # # FRETE SEDEX HOJE = 40290 # # FRETE E-SEDEX = 81019 # # FRETE MALOTE = 44105 # # FRETE NORMAL = 41017 # # SEDEX A COBRAR = 40045 # ##################################### $nCdEmpresa = ""; $sDsSenha = ""; $nCdServico = $_POST['TENVIO']; $sCepOrigem = 36855000; $sCepDestino = $_POST['TCEP']; $sCepDestino = eregi_replace("([^0-9])","",$sCepDestino); $nVlPeso = $peso_medio; $nCdFormato = 1; $nVlComprimento = 20; $nVlAltura = 20; $nVlLargura = 20; $nVlDiametro = 0; $sCdMaoPropria = "N"; $nVlValorDeclarado = 0; $sCdAvisoRecebimento = "S"; // URL de Consulta dos Correios entregue à variavel $correios $correios ="http://shopping.correios.com.br/wbm/shopping/script/CalcPrecoPrazo.aspx?" ."nCdEmpresa=$nCdEmpresa&" ."sDsSenha=$sDsSenha&" ."sCepOrigem=$sCepOrigem&" ."sCepDestino=$sCepDestino&" ."nVlPeso=$nVlPeso&" ."nCdFormato=$nCdFormato&" ."nVlComprimento=$nVlComprimento&" ."nVlAltura=$nVlAltura&" ."nVlLargura=$nVlLargura&" ."sCdMaoPropria=$sCdMaoPropria&" ."nVlValorDeclarado=$nVlValorDeclarado&" ."sCdAvisoRecebimento=$sCdAvisoRecebimento&" ."nCdServico=$nCdServico&" ."nVlDiametro=$nVlDiametro&" ."StrRetorno=xml"; $dados_correios = simplexml_load_file($correios); //print_r($dados_correios); print "<p>"; $total = $dados_correios->xpath('cServico/Valor'); $total = floatval(str_replace(',', '.', $total[0])); $PrazoEntrega = $dados_correios->xpath('cServico/PrazoEntrega'); $erros = $dados_correios->xpath('cServico/Erro'); $ValorAvisoRecebimento = $dados_correios->xpath('cServico/ValorAvisoRecebimento'); if ($erros[0] != 0) { // Tratamento dos Erros //CEP de destino inválido if ($erros[0] == -3) { Print "CEP de destino inválido.<br> Cloque <a href='java script:window.history.go(-1)'>Aqui</a> e tente um novo CEP!"; echo "<script>document.FORM.Finalizar.disabled=true;</script>"; } //Sistema temporariamente fora do ar. Favor tentar mais tarde. else if ($erros[0] == -33) { Print "Sistema dos correios temporariamente fora do ar.<br> Por favor navegue um pouco mais pelo site e após alguns segundos, tente novamente!"; echo "<script>document.FORM.Finalizar.disabled=true;</script>"; } //Serviço indisponível para o trecho informado. else if ($erros[0] == -6) { echo "<script>alert('Sistema dos correios indisponível para o trecho informado');</script>"; session_unregister("MeuCarrinho"); echo "<script>document.location='produtos.php?acao=listar'</script>"; } //Para qualquer outro erro else { Print "CEP de destino inválido ou erro no sistema dos correios.<br> Cloque <a href='java script:window.history.go(-1)'>Aqui</a> e tente um novo CEP!"; echo "<script>document.FORM.Finalizar.disabled=true;</script>"; } } else { print $FORM_ENDERECO; switch ($nCdServico) { case 41106: $nome_servico = " PAC "; break; case 40010: $nome_servico = " SEDEX "; break; } ?> <TABLE width='400' align='center'><tr> <TD>VALORES:</TD> <TD> <? print "O valor da sua compra sem o frete R$ "; print number_format($preco_total, 2, ',', '.'); print "<p>"; print "O valor do envio por "; print $nome_servico; print " será de: R$"; print number_format($total, 2, ',', '.'); print "<p>"; print "O prazo de entrega será de "; print $PrazoEntrega[0]; print " dia(s) úteis"; print "<p>"; $valor_final = $total + $preco_total; print "O valor da tua compra com o frete R$ "; print number_format($valor_final, 2, ',', '.'); ?> </td></tr></table> <? } // Neste exemplo estou colocando apenas PAC e SEDEX ?> -
desabiltar um botão submit (ou button) de um formulario
pergunta respondeu ao Carlos Rocha de Carlos Rocha em Ajax, JavaScript, XML, DOM
Seguinte: Não deu certo. Na verdade eu até consegui desativar o form todo mas quanmdo cliko nbo botao submit, mesmo desativado ele envia o formulario. Veja o meu form: <FORM METHOD="POST" ACTION="CarrinhoFinal.php?acao=gravar_pedido" name="FORM"> <INPUT TYPE="hidden" NAME="FORM" VALUE="FORM"> <INPUT TYPE="hidden" NAME="peso_medio" VALUE="<?=$peso_medio;?>"> <input type="hidden" name="TENVIO" value="<?=$TENVIO; ?>"> <input type="hidden" name="TCEP" value="<?=$TCEP; ?>"> <input type="hidden" name="Id_Cliente" value="<?=$SESSAOlogin; ?>"> <TABLE width="400" align="center"> <tr><td colspan="2" align="center"><h2><b>Finalizando Compra</b></h2></td></tr> <TR> <TD>PAGAMENTO </TD> <TD> <!-- <div id="cartao" style="display:block;">oi</div> onclick="java script: fecha('cartao');" --> <INPUT type="radio" NAME="TPGTO" value="MASTERCARD" checked="checked"> MASTERCARD <br> <INPUT type="radio" NAME="TPGTO" value="BOLETO"> BOLETO (À Vista)<br> <INPUT type="radio" NAME="TPGTO" value="DEPOSITO"> DEPÓSITO (À Vista) </TD> </TR> <TR> <TD>NOME:/RAZÃO SOCIAL </TD> <TD><INPUT TYPE="text" NAME="TNOME" value="<?=$nome;?>" disabled="disabled"></TD> </TR> <TR> <TD>CPF/CNPJ:</TD> <TD><INPUT TYPE="text" NAME="TCPF" value="<?=$cpfcnpj;?>" disabled="disabled"></TD> </TR> <TR> <TD>EMAIL:</TD> <TD><INPUT TYPE="text" NAME="TEMAIL" value="<?=$email;?>" disabled="disabled"></TD> </TR> <TR> <TD>ENDEREÇO: <font color="red">(de entrega)</font></TD> <TD><INPUT TYPE="text" NAME="TENDERECO" value="<?=$endereco;?>"></TD> </TR> <TR> <TD>BAIRRO:</TD> <TD><INPUT TYPE="text" NAME="TBAIRRO" value="<?=$bairro;?>"></TD> </TR> <TR> <TD>CIDADE:</TD> <TD><INPUT TYPE="text" NAME="TCIDADE" value="<?=$cidade;?>"></TD> </TR> <TR> <TD>ESTADO:</TD> <TD><INPUT TYPE="text" NAME="TESTADO" value="<?=$estado;?>"></TD> </TR> <TR> <TD>FONE (Contato):</TD> <TD><INPUT TYPE="text" NAME="TFONE" value="<?=$tel;?>"></TD> </TR> <TR> <TD>VALORES:</TD> <TD> <? include ("frete.php"); ?> <input type="hidden" name="valor_final" value="<?=$valor_final; ?>"> </TD> </TR> <TR align="center"> <TD colspan="2"><input type="submit" id="Finalizar" name="Finalizar" value="Finalizar" WIDTH="78" HEIGHT="20" style="background-color: rgb(0,111,55); color: rgb(255,255,0)" onClick="CriticaFormulario()"></TD> </TR> </TABLE> </FORM> Essa pagin que esta com, include, frete.php, tem um codigo que m,e retorna um, xml do correio e é trabalhado no frete.php memo. Lá, se por acaso, houver erro, eu quero que no carregamento do form todo fique desativado.; Segue o codigo do frete.php <?php ##################################### # Código dos Serviços dos Correios # # FRETE PAC = 41106 # # FRETE SEDEX = 40010 # # FRETE SEDEX 10 = 40215 # # FRETE SEDEX HOJE = 40290 # # FRETE E-SEDEX = 81019 # # FRETE MALOTE = 44105 # # FRETE NORMAL = 41017 # # SEDEX A COBRAR = 40045 # ##################################### $nCdEmpresa = ""; $sDsSenha = ""; $nCdServico = $_POST['TENVIO']; $sCepOrigem = 36855000; $sCepDestino = $_POST['TCEP']; $sCepDestino = eregi_replace("([^0-9])","",$sCepDestino); $nVlPeso = $peso_medio; $nCdFormato = 1; $nVlComprimento = 20; $nVlAltura = 20; $nVlLargura = 20; $nVlDiametro = 0; $sCdMaoPropria = "N"; $nVlValorDeclarado = 0; $sCdAvisoRecebimento = "S"; // URL de Consulta dos Correios entregue à variavel $correios $correios ="http://shopping.correios.com.br/wbm/shopping/script/CalcPrecoPrazo.aspx?" ."nCdEmpresa=$nCdEmpresa&" ."sDsSenha=$sDsSenha&" ."sCepOrigem=$sCepOrigem&" ."sCepDestino=$sCepDestino&" ."nVlPeso=$nVlPeso&" ."nCdFormato=$nCdFormato&" ."nVlComprimento=$nVlComprimento&" ."nVlAltura=$nVlAltura&" ."nVlLargura=$nVlLargura&" ."sCdMaoPropria=$sCdMaoPropria&" ."nVlValorDeclarado=$nVlValorDeclarado&" ."sCdAvisoRecebimento=$sCdAvisoRecebimento&" ."nCdServico=$nCdServico&" ."nVlDiametro=$nVlDiametro&" ."StrRetorno=xml"; $dados_correios = simplexml_load_file($correios); //print_r($dados_correios); print "<p>"; $total = $dados_correios->xpath('cServico/Valor'); $total = floatval(str_replace(',', '.', $total[0])); $PrazoEntrega = $dados_correios->xpath('cServico/PrazoEntrega'); $erros = $dados_correios->xpath('cServico/Erro'); $ValorAvisoRecebimento = $dados_correios->xpath('cServico/ValorAvisoRecebimento'); if ($erros[0] != 0) { // Tratamento dos Erros //CEP de destino inválido if ($erros[0] == -3) { Print "CEP de destino inválido.<br> Cloque <a href='java script:window.history.go(-1)'>Aqui</a> e tente um novo CEP!"; echo "<script>document.FORM.Finalizar.disabled=true;</script>"; } if ($erros[0] == -10) { Print "CEP de destino inválido.<br> Cloque <a href='java script:window.history.go(-1)'>Aqui</a> e tente um novo CEP!"; echo "<script>document.getElementById('Finalizar').disabled = 'true';</script>"; } //Sistema temporariamente fora do ar. Favor tentar mais tarde. else if ($erros[0] == -33) { Print "Sistema dos correios temporariamente fora do ar.<br> Por favor navegue um pouco mais pelo site e após alguns segundos, tente novamente!"; echo "<script>document.FORM.Finalizar.disabled=true;</script>"; } //Serviço indisponível para o trecho informado. else if ($erros[0] == -6) { echo "<script>alert('Sistema dos correios indisponível para o trecho informado');</script>"; session_unregister("MeuCarrinho"); echo "<script>document.location='produtos.php?acao=listar'</script>"; } //Para qualquer outro erro else { session_destroy(); echo "<script>document.location='produtos.php?acao=listar'</script>";} } else { print "O valor do envio por "; print $nome_servico; print " será de: R$"; print number_format($total, 2, ',', '.'); print "<br>e o prazo de entrega será de "; print $PrazoEntrega[0]; print " dia(s) úteis"; print "<p>"; print "Valor da compra sem o frete R$ "; print number_format($preco_total, 2, ',', '.'); print "<p>"; $valor_final = $total + $preco_total; print "Valor da compra com o frete R$ "; print number_format($valor_final, 2, ',', '.'); } // Neste exemplo estou colocando apenas PAC e SEDEX ?> -
desabiltar um botão submit (ou button) de um formulario
pergunta respondeu ao Carlos Rocha de Carlos Rocha em Ajax, JavaScript, XML, DOM
Cara, tentei assim la no php e não deu certo: if ($erros[0] == -10) { Print "CEP de destino inválido.<br> Cloque <a href='java script:window.history.go(-1)'>Aqui</a> e tente um novo CEP!"; echo "<scriptdocument.getElementById('Finalizar').disabled = 'disabled';</script>"; } Obs.: Essa parte $erros[0] == -10 esta numa parte do form No form <input type="submit" id="Finalizar" name="Finalizar" value="Finalizar" WIDTH="78" HEIGHT="20" style="background-color: rgb(0,111,55); color: rgb(255,255,0)" onClick="CriticaFormulario()"> que esta errado? -
desabiltar um botão submit (ou button) de um formulario
pergunta respondeu ao Carlos Rocha de Carlos Rocha em Ajax, JavaScript, XML, DOM
Entendi sim mas não é isso não. Olha só. Eu estou preenchendo um, forma que tem só login e senha (até ai esta ok?) Bom, o usuario é valido (existe) então coleto tambem o campo Bloqueio da tabela de usuarios no MySql referente a esse usuario. (até ai esta ok?) Dai eu derivo (envio) o login e senha e o bloqueio do usuario para um outro formulario onde ele estará preenchendo outros dados como por exemplo endereço, tel... (até ai esta ok?) Bom, se o Bloqueio receber N, o botão submite do form fica normal, se o Bloqueio receber S, ai eu preciso desabilitar o botão submit (ou todo o form) para o usuario não poder prosseguir com o cadastro. Tendeu? -
desabiltar um botão submit (ou button) de um formulario
pergunta respondeu ao Carlos Rocha de Carlos Rocha em Ajax, JavaScript, XML, DOM
beleza irmão? Seguinte: um form tem la os campos: nome, endereço, tel, etc. Certo? E tambem tem o botõ submit para enviar o form. certo? Então, quero uma função que desabilite este boitão submit mas que esta função estee em outro componente e não no proprio onclick do botão. Tendeu irmão? Na verdade estou tendo um rerorno do php que, dependendo deste retrorno não posso liberar o form para envio. Sacou? No aguardo!