Welcome guest, is this your first visit? Click the "Create Account" button now to join.

User Tag List

Resultados 1 a 10 de 10
  1. #1
    rocksul
    Guest

    Ajuda em PHP - Iniciante

    Oi galera!
    Me pediram pra fazer um form aqui na empresa pra colocar no çaite. Daí fui atrás duns em PHP e fiz um baseado em modelos dos caras, é tipo uma página que recebe os dados e valida, se funfou vai para uma próxima página que grava os dados no banco de dados e envia os dados por email pra alguém.
    O meu problema é que o email não tá enviando, tá gravando no banco de dados tudo certinho. Não achei o erro, já testei N vezes mas não dá certo. Se alguém entende de PHP e puder me ajudar agradeço, desde domingo tô tentando fazê essa erva funfa e nada.

    [hr]Página que recebe os dados[hr]
    <!--Início do arquivo-->
    <link href="css/style.css" rel="stylesheet" type="text/css">
    <script language="JavaScript" type="text/JavaScript">
    //Valida campos em branco
    <!--
    function MM_findObj(n, d) { //v4.01
    var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
    if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms(i)[n];
    for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers(i).document);
    if(!x && d.getElementById) x=d.getElementById(n); return x;
    }
    //coloquei os "i" entre parenteses pq não dá pra colocar entre colchetes no fórum
    function MM_validateForm() { //v4.0
    var i,p,q,nm,test,num,min,max,errors='',args =MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args(i));
    if (val) { nm=val.name; if ((val=val.value)!="") {
    if (test.indexOf('isEmail&#039!=-1) { p=val.indexOf('@'
    if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
    } else if (test!='R&#039 { num = parseFloat(val);
    if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
    if (test.indexOf('inRange&#039 != -1) { p=test.indexOf(':'
    min=test.substring(8,p); max=test.substring(p+1);
    if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R&#039 errors += '- '+nm+' is required.\n'; }
    } if (errors) alert('The following error(s) occurredn'+errors);
    document.MM_returnValue = (errors == ''
    }
    //-->
    //fim da validação
    </script>
    <!--Início do form -->
    <table width="772" border="0" cellspacing="0" cellpadding="0">
    <tr valign="top">
    <td colspan="2" valign="top"><img src="images/tit_trabalhe.jpg" width="397" height="48"></td>
    <td width="375" rowspan="2" valign="middle" bgcolor="#FFFFFF"><div align="center"><img src="images/sunset_04.jpg" width="373" height="17"> <img src="images/trabalhe_bg_image.jpg" width="340" height="471"></div></td>
    </tr>
    <tr valign="top">
    <td width="14"><img src="images/sunset_06.jpg" width="14" height="444" alt=""></td>
    <td width="383" background="images/bg_trabalhe.jpg"><div align="center"><br>
    Envie seu currículo e venha fazer parte de nossa família.
    <form action="index.php" method="post" name="form1" onSubmit="MM_validateForm('nome','& #039;,'R','email','' ,'RisEmail','celular','&# 039;,'RisNum','telefone',&#039 ;','RisNum','emprego_3',& #039;','R','emprego_2',&# 039;','R','emprego_1',&#0 39;','R','ocupacao',&#039 ;','R','porque','&#0 39;,'R'return document.MM_returnValue">
    <table width="342" border="0" cellspacing="5" cellpadding="2">
    <tr valign="top">
    <td width="122"><strong>Nome:</strong></td>
    <td width="197"><input name="nome" type="text" class="form" id="nome" size="30"></td>
    </tr>
    <tr valign="top">
    <td><strong>Email:</strong></td>
    <td><input name="email" type="text" class="form" id="email" size="30"></td>
    </tr>
    <tr valign="top">
    <td>Celular:</td>
    <td><input name="celular" type="text" class="form" id="celular"></td>
    </tr>
    <tr valign="top">
    <td>Telefone:</td>
    <td><input name="telefone" type="text" class="form" id="telefone"></td>
    </tr>
    <tr valign="top">
    <td>Cargo Pretendido:</td>
    <td><input name="cargo" type="text" class="form" id="cargo" /></td>
    </tr>
    <tr valign="top">
    <td>Ocupação Atual:</td>
    <td><textarea name="ocupacao" cols="28" class="form" id="ocupacao"></textarea></td>
    </tr>
    <tr valign="top">
    <td>Experiência em lojas: </td>
    <td><input name="experiencia" type="radio" value="sim" />
    sim

    <input name="experiencia" type="radio" value="não" />
    não </td>
    </tr>
    <tr valign="top">
    <td colspan="2">Últimos 3 empregos + Contato:</td>
    </tr>
    <tr valign="top">
    <td colspan="2"><div align="left">3º
    <input name="emprego_3" type="text" class="form" id="emprego_3" size="53" />
    </div></td>
    </tr>
    <tr valign="top">
    <td colspan="2"><div align="left">2º
    <input name="emprego_2" type="text" class="form" id="emprego_2" size="53" />
    </div></td>
    </tr>
    <tr valign="top">
    <td colspan="2"><div align="left">1º
    <input name="emprego_1" type="text" class="form" id="emprego_1" size="53" />
    </div></td>
    </tr>
    <tr valign="top">
    <td colspan="2"><div align="justify">Diga em poucas palavras porque você gostaria de trabalhar na Sunset? </div></td>
    </tr>
    <tr valign="top">
    <td colspan="2"><textarea name="porque" cols="54" rows="4" class="form" id="porque"></textarea></td>
    </tr>
    <tr valign="top">
    <td colspan="2"><input type="submit" name="Submit" value="Enviar seus dados">
    <!--passa para a próxima página os parâmetros -->
    <input name="go" type="hidden" id="go" value="script_trabalhe" /></td>
    <!--chamada da página script_trabalhe.php deve ser chamada -->
    </tr>
    </table>
    </form>
    </div></td>
    </tr>
    </table>
    <!--Fim do arquivo-->

    [hr]Página que grava no banco, envia o email e motra pro usuário uma página dizendo "Sua mensagem foi enviada" - isso é mentira a mensagem não foi enviada! Só tá gravada no banco de dados, ela não vai! Phorra![hr]
    <!--Início do PHP -->
    <?
    $from = "$email"; //Recupera o email da página anterior
    $title = "Currículo: $nome"; //Grava na variável $title "curriculo: +(nome recuperado da página anterior
    $para="[email protected]"; //email de destino do form

    $headers .= "MIME-Version: 1.0\r\n"; //Formatação do email
    $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; //Formatação do email
    $headers .="From: $nome"; //Cabeçalho da mensagem recebida por email

    require_once('Connections/Conn_Website.php' //verifica existência do arquivo
    mysql_select_db($database_Conn_Website, $Conn_Website); // conecta ao banco

    mysql_query("insert into vagas (nome, sexo, email, celular, telefone, cargo, ocupacao, experiencia, emprego_3,emprego_1, porque, IP) values ('$nome', '$sexo', '$email', '$celular', '$telefone', '$cargo', '$ocupacao', '$experiencia','$ emprego_3','$emprego_1', '$porque','".$REMOTE_ADDR."&#039") or die(mysql_error()); //grava variáveis trazidas da página anterior na tabela

    //corpo da mensagem que será inserida no email, este corpo utiliza formatação de texto
    $body="
    <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtm....dtd'>
    <html xmlns='http://www.w3.org/1999/xhtml'>
    <head>
    <meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1' />
    <title>Currículo recebido!</title>
    <style type='text/css'>
    <!--
    body {
    margin-left: 0px;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
    background-color: #FFFFFF;
    }
    body,td,th {
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 10px;
    }
    .Brd {
    border: 1px solid #CFCFCF;
    }
    -->
    </style>
    </head>

    <body>
    <table width='550' border='0' align='center' cellpadding='0' cellspacing='0' class='Brd'>
    <tr>
    <td><div align='center'></td>
    </tr>
    <tr>
    <td><p> </p>
    <blockquote>
    <p><b>Nome:</b> $nome</p>
    <p><b>Email:</b> $email</p>
    <p><b>Celular:</b> $celular</p>
    <p><b>Telefone:</b> $telefone </p>
    <p><b>Endereço:</b> $ocupacao</p>
    <p><b>Cargo Pretendido:</b> $cargo</p>
    <p><b>Experiencia:</b> $experiencia</p>
    <p><b>Últimos 3 empregos + Contato:</b></p>
    <p><b>Última ocupação:</b> $emprego_3</p>
    <p><b>Penúltima ocupação:</b> $emprego_2</p>
    <p><b>Antepenúltima ocupação:</b> $emprego_1</p>
    <p><b>Gostaria de trabalhar na Sunset porque:</b> $porque</p>
    <p> </p>
    <p><b>Ip de origem: </b>".$REMOTE_ADDR." </p>

    </blockquote></td>
    </tr>
    <tr>
    <td height='50'><div align='center'>http://www.sunsetsurfstreet.com.br</...gt;</td>
    </tr>
    </table>
    </body>
    </html>

    ";
    //fim do corpo, buscando as variáveis da página anterior e inserindo as mesmas no corpo pré-formatado

    //Função mail do PHP - mail (endereço de destino,titulo da mensagem, mensagem, cabeçalho da mensagem);
    mail($para,$title,$body,$headers);
    ?>
    <!--Fim do PHP, Página exibida após envio da mensagem -->
    <link href="css/style.css" rel="stylesheet" type="text/css">

    <table width="772" border="0" cellspacing="0" cellpadding="0">
    <tr valign="top">
    <td colspan="2"><img src="images/tit_trabalhe.jpg" width="397" height="48"></td>
    <td width="375" rowspan="2" bgcolor="#FFFFFF"><div align="center"><img src="images/sunset_04.jpg" width="373" height="17"> <img src="images/trabalhe_bg_image.jpg" width="340" height="471"></div></td>
    </tr>
    <tr valign="top">
    <td width="14"><img src="images/sunset_06.jpg" width="14" height="444" alt=""></td>
    <td width="383" background="images/bg_trabalhe.jpg"><div align="center">
    <p> </p>
    <p> </p>
    <p> </p>
    <table width="331" border="0" align="center" cellpadding="2" cellspacing="2">
    <tr>
    <td> </td>
    </tr>
    <tr>
    <td><p align="center"> </p>
    <p align="center">Caro(a) <span class="roxo"><strong><?php echo $nome; ?></strong></span>, seus dados foram enviados com sucesso!!!</p>
    <p align="center">Obrigado por entrar em contato conosco. </p>
    </td>
    </tr>
    </table>
    </div></td>
    </tr>
    </table>

    <!--Fim do arquivo -->

    [hr]
    Se alguém puder me ajudar, agradeço! Vlw!

  2. #2
    Usuário de motoneta
    Data de Ingresso
    Apr 2007
    Localização
    Curitiba - Pr
    Idade
    41
    Posts
    127

    Re: Ajuda em PHP - Iniciante

    Kra acho mais facil vc organizar seu codigo...
    Vc faz o envio de email e salva os dados no mesmo script, tente organizar com Classes.
    Outra coisa costume debugar seu código com echo ou print...
    <b>Catinga de ** e vazamento de Opala ninguém tira</b>
    <b>Ligeiro é o Pato que nasce com os dedos colados pra não usar aliança</b>
    <b>Esperto é o Carangueijo que anda de lado para não deixar o dele na reta</b>
    <b>Magrelas:</b> CG 150 KS - 06[VENDIDA]
    <b>Magrelas:</b> NX4 FALCON 08[ATUAL]

  3. #3
    rocksul
    Guest

    Re: Ajuda em PHP - Iniciante

    Citação Postado originalmente por Sh3rMy Ver Post
    Kra acho mais facil vc organizar seu codigo...
    Vc faz o envio de email e salva os dados no mesmo script, tente organizar com Classes.
    Outra coisa costume debugar seu código com echo ou print...
    Fiz debug com echo assim
    $envia = mail($para,$title,$body,$headers);

    if ($envia)
    echo "foi essa erva";
    else
    echo "essa erva não foi";

    deu a resposta "foi esa erva" mas não chega nada no email.

    ... cara essa é minha primeira página em PHP... não procurei como funfam as classes aqui, mas d qlquer forma, vlw pela ajuda.

  4. #4
    Motociclista
    Data de Ingresso
    Oct 2006
    Localização
    São Vicente - SP
    Idade
    42
    Posts
    1.708

    Re: Ajuda em PHP - Iniciante

    rock, faz um teste rápido:

    mail($para,$title,$body,$headers);

    ao invés de passar as variáveis desse jeito, faz 1x na munheca pra ver como fica!

    tipo assim: mail("seuemail@email", "aaa","teste","teste")

    pode ser aí que tá o pau!

    http://www.imasters.com.br/artigo/278/php/funcao_mail_/


    EDIT: otro!

    http://www.criarweb.com/artigos/189.php
    *******************

  5. #5
    rocksul
    Guest

    Re: Ajuda em PHP - Iniciante

    Daí vai!

  6. #6
    Super Piloto
    Data de Ingresso
    Nov 2006
    Localização
    Jandira - SP
    Idade
    41
    Posts
    6.414

    Re: Ajuda em PHP - Iniciante

    Então Manda Debugar suas variaveis...

    As vezes tu não esta "pegando" ela corretamente!
    [img width=363 height=130]http://www.baloonfestas.com.br/temas/tema-corinthians/banner_corintians.jpg[/img]
    EU NUNCA VOU TE ABANDONAR......

  7. #7
    Iniciante
    Data de Ingresso
    Aug 2007
    Posts
    86

    Re: Ajuda em PHP - Iniciante

    Ae rocksul, eu uso esse script, o FormM@iler, fácil de configurar...
    Vo colar aqui pois a página dele parece não estar funcionando.


    formmailer.php:
    <?php
    ////////////////////////////////////////////////////////////////////////////
    // dB Masters' PHP FormM@iler, Copyright (c) 2007 dB Masters Multimedia
    // FormMailer comes with ABSOLUTELY NO WARRANTY
    // Licensed under the AGPL
    // See license.txt and readme.txt for details
    ////////////////////////////////////////////////////////////////////////////
    // General Variables
    $check_referrer="no";
    $referring_domains="http://domain.com/,http://www.domain....domain.com/";

    // options to use if hidden field "config" has a value of 0
    // recipient info
    $charset[0]="iso-8859-1";
    $tomail[0]="[email protected]";
    $cc_tomail[0]="";
    $bcc_tomail[0]="";
    // Mail contents config
    $subject[0]="Contato";
    $reply_to_field[0]="Email";
    $reply_to_name[0]="Nome";
    $required_fields[0]="Nome,Email,Telefone";
    $required_email_fields[0]="Email";
    $attachment_fields[0]="";
    $return_ip[0]="yes";
    $mail_intro[0]="Contato In design:";
    $mail_fields[0]="Nome,Email,Empresa,Telefone";
    $mail_type[0]="text";
    $mail_priority[0]="1";
    $allow_html[0]="no";
    // Send back to sender config
    $send_copy[0]="no";
    $send_copy_format[0]="vert_table";
    $send_copy_fields[0]="Name,Comments";
    $send_copy_attachment_fields[0]="";
    $copy_subject[0]="Subject of Copy Email";
    $copy_intro[0]="Thanks for your inquiry, the following message has been delivered.";
    $copy_from[0]="[email protected]";
    $copy_tomail_field[0]="Email";
    // Result options
    $header[0]="";
    $footer[0]="";
    $error_page[0]="";
    $thanks_page[0]="";
    // Default Error and Success Page Variables
    $error_page_title[0]="Error - Missed Fields";
    $error_page_text[0]="Please use your browser's back button to return to the form and complete the required fields.";
    $thanks_page_title[0]="Message Sent";
    $thanks_page_text[0]="Thank you for your inquiry";
    $thanks_page[0]="obrigado.html";
    $error_page[0]="erro.html";

    // options to use if hidden field "config" has a value of 1
    // recipient info
    $charset[1]="";
    $tomail[1]="";
    $cc_tomail[1]="";
    $bcc_tomail[1]="";
    // Mail contents config
    $subject[1]="";
    $reply_to_field[1]="";
    $reply_to_name[1]="";
    $required_fields[1]="";
    $required_email_fields[1]="";
    $attachment_fields[1]="";
    $return_ip[1]="";
    $mail_intro[1]="";
    $mail_fields[1]="";
    $mail_type[1]="";
    $mail_priority[1]="";
    $allow_html[1]="";
    // Send back to sender config
    $send_copy[1]="";
    $send_copy_format[1]="";
    $send_copy_fields[1]="";
    $send_copy_attachment_fields[1]="";
    $copy_subject[1]="";
    $copy_intro[1]="";
    $copy_from[1]="";
    $copy_tomail_field[1]="";
    // Result options
    $header[1]="";
    $footer[1]="";
    $error_page[1]="";
    $thanks_page[1]="";
    // Default Error and Success Page Variables
    $error_page_title[1]="";
    $error_page_text[1]="";
    $thanks_page_title[1]="";
    $thanks_page_text[1]="";

    /////////////////////////////////////////////////////////////////////////
    // Don't muck around past this line unless you know what you are doing //
    /////////////////////////////////////////////////////////////////////////

    ob_start();
    $config=$_POST["config"];
    $debug=0;
    $reply_to_field=$reply_to_field[$config];
    $copy_tomail_field=$copy_tomail_field[$config];

    // fix for Windows email server security
    ini_set("sendmail_from",$tomail[$config]);

    // email validation regular expression
    $regex = "^[-a-z0-9!#$%&\'*+/=?^_`{|}~]+(\.[-a-z0-9!#$%&\'*+/=?^_`{|}~]+)*@(([a-z]([-a-z0-9]*[a-z0-9]+)?){1,63}\.)+([a-z]([-a-z0-9]*[a-z0-9]+)?){2,63}$";
    $header_injection_regex = "(\r|\n)(tofromccbcc";

    if($header[$config]!="")
    include($header[$config]);

    if($_POST["submit"] || $_POST["Submit"] || $_POST["submit_x"] || $_POST["Submit_x"])
    {

    ////////////////////////////
    // begin global functions //
    ////////////////////////////
    // get visitor IP
    function getIP()
    {
    if(getenv(HTTP_X_FORWARDED_FOR))
    $user_ip=getenv("HTTP_X_FORWARDED_FOR");
    else
    $user_ip=getenv("REMOTE_ADDR");
    return $user_ip;
    }
    // get value of given key
    function parseArray($key)
    {
    $array_value=$_POST[$key];
    $count=1;
    extract($array_value);
    foreach($array_value as $part_value)
    {
    if($count > 1){$value.=", ";}
    $value.=$part_value;
    $count=$count+1;
    }
    return $value;
    }
    // stripslashes and autolink url's
    function parseValue($value)
    {
    $value=preg_replace("/(http/\/+.[^\s]+)/i",'<a href="\\1">\\1</a>', $value);
    return $value;
    }
    // html header if used
    function htmlHeader()
    {
    $htmlHeader="<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">\n<html>\n<head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=".$charset[$config]."\"></head>\n<body>\n<table cellpadding=\"2\" cellspacing=\"0\" border=\"0\" width=\"600\">\n";
    return $htmlHeader;
    }
    // html footer if used
    function htmlFooter()
    {
    $htmlFooter="</table>\n</body>\n</html>\n";
    return $htmlFooter;
    }
    // build verticle table format
    function buildVertTable($fields, $intro, $to, $send_ip)
    {
    $message=htmlHeader();
    if($intro != "")
    $message.="<tr>\n<td align=\"left\" valign=\"top\" colspan=\"2\">".$intro."</td>\n</tr>\n";
    $fields_check=preg_split('/,/',$fields);
    $run=sizeof($fields_check);
    for($i=0;$i<$run;$i++)
    {
    $cur_key=$fields_check[$i];
    $cur_value=$_POST[$cur_key];
    if(is_array($cur_value))
    {
    $cur_value=parseArray($cur_key);
    }
    $cur_value=parseValue($cur_value);
    if($allow_html[$config]=="no")
    $cur_value=htmlspecialchars(nl2br($cur_value));
    else
    $cur_value=nl2br($cur_value);
    $message.="<tr>\n<td align=\"left\" valign=\"top\" style=\"white-space:nowrap;\"><b>".$cur_key."</b></td>\n<td align=\"left\" valign=\"top\" width=\"100%\">".$cur_value."</td>\n</tr>\n";
    }
    if($send_ip=="yes" && $to=="recipient")
    {
    $user_ip=getIP();
    $message.="<tr>\n<td align=\"left\" valign=\"top\" style=\"white-space:nowrap;\"><b>Sender IP</b></td>\n<td align=\"left\" valign=\"top\" width=\"100%\">".$user_ip."</td>\n</tr>\n";
    }
    $message.=htmlFooter();
    return $message;
    }
    // build horizontal table format
    function buildHorzTable($fields, $intro, $to, $send_ip)
    {
    $message=htmlHeader();
    $fields_check=preg_split('/,/',$fields);
    $run=sizeof($fields_check);
    if($intro != "")
    $message.="<tr>\n<td align=\"left\" valign=\"top\" colspan=\"".$run."\">".$intro."</td>\n</tr>\n";
    $message.="<tr>\n";
    for($i=0;$i<$run;$i++)
    {
    $cur_key=$fields_check[$i];
    $message.="<td align=\"left\" valign=\"top\" style=\"white-space:nowrap;\"><b>".$cur_key."</b></td>\n";
    }
    if($send_ip=="yes" && $to=="recipient")
    $message.="<td align=\"left\" valign=\"top\" style=\"white-space:nowrap;\"><b>Sender IP</b></td>\n";
    $message.="</tr>\n";
    $message.="<tr>\n";
    for($i=0;$i<$run;$i++)
    {
    $cur_key=$fields_check[$i];
    $cur_value=$_POST[$cur_key];
    if(is_array($cur_value))
    {
    $cur_value=parseArray($cur_key);
    }
    $cur_value=parseValue($cur_value);
    if($allow_html[$config]=="no")
    $cur_value=htmlspecialchars(nl2br($cur_value));
    else
    $cur_value=nl2br($cur_value);
    $message.="<td align=\"left\" valign=\"top\">".$cur_value."</td>\n";
    }
    $message.="</tr>\n";
    $message.="<tr>\n";
    if($send_ip=="yes" && $to=="recipient")
    {
    $user_ip=getIP();
    $message.="<td align=\"left\" valign=\"top\">".$user_ip."</td>\n";
    }
    $message.="</tr>\n";
    $message.=htmlFooter();
    return $message;
    }
    // build plain text format
    function buildTextTable($fields, $intro, $to, $send_ip)
    {
    $message="";
    if($intro != "")
    $message.=$intro."\n\n";
    $fields_check=preg_split('/,/',$fields);
    $run=sizeof($fields_check);
    for($i=0;$i<$run;$i++)
    {
    $cur_key=$fields_check[$i];
    $cur_value=$_POST[$cur_key];
    if(is_array($cur_value))
    {
    $cur_value=parseArray($cur_key);
    }
    $cur_value=parseValue($cur_value);
    if($allow_html[$config]=="no")
    $cur_value=htmlspecialchars($cur_value);
    else
    $cur_value=$cur_value;
    $message.="".$cur_key.": ".$cur_value."\n";
    }
    if($send_ip=="yes" && $to=="recipient")
    {
    $user_ip=getIP();
    $message.="Sender IP: ".$user_ip."\n";
    }
    return $message;
    }
    // get the proper build fonction
    function buildTable($format, $fields, $intro, $to, $send_ip)
    {
    if($format=="vert_table")
    $message=buildVertTable($fields, $intro, $to, $send_ip);
    else if($format=="horz_table")
    $message=buildHorzTable($fields, $intro, $to, $send_ip);
    else
    $message=buildTextTable($fields, $intro, $to, $send_ip);
    return $message;
    }
    // referrer checking security option
    function checkReferer()
    {
    if($check_referrer=="yes")
    {
    $ref_check=preg_split('/,/',$referring_domains);
    $ref_run=sizeof($ref_check);
    $referer=$_SERVER['HTTP_REFERER'];
    $domain_chk="no";
    for($i=0;$i<$ref_run;$i++)
    {
    $cur_domain=$ref_check[$i];
    if(stristr($referer,$cur_domain)){$domain_chk="yes ";}
    }
    }
    else
    {
    $domain_chk="yes";
    }
    return $domain_chk;
    }
    // checking required fields and email fields
    function checkFields($text_fields, $email_fields, $regex)
    {
    $error_message="";
    if($debug==1)
    $error_message.="<li>text_fields: ".$text_fields."<br />email_fields: ".$email_fields."<br />reply_to_field: ".$reply_to_field."<br />reply_to_name: ".reply_to_name."</li>";
    if($text_fields != "")
    {
    $req_check=preg_split('/,/',$text_fields);
    $req_run=sizeof($req_check);
    for($i=0;$i<$req_run;$i++)
    {
    $cur_field_name=$req_check[$i];
    $cur_field=$_POST[$cur_field_name];
    if($cur_field=="")
    {
    $error_message.="<li>You are missing the <b>".$req_check[$i]."</b> field</li>\n";
    }
    }
    }
    if($email_fields != "")
    {
    $email_check=preg_split('/,/',$email_fields);
    $email_run=sizeof($email_check);
    for($i=0;$i<$email_run;$i++)
    {
    $cur_email_name=$email_check[$i];
    $cur_email=$_POST[$cur_email_name];
    if($cur_email=="" || !eregi($regex, $cur_email))
    {
    $error_message.="<li>You are missing the <b>".$email_check[$i]."</b> field or it is not a valid email address.</li>\n";
    }
    }
    }
    return $error_message;
    }
    // attachment function
    function getAttachments($attachment_fields, $message, $content_type, $border)
    {
    $att_message="This is a multi-part message in MIME format.\r\n";
    $att_message.="--{$border}\r\n";
    $att_message.=$content_type."\r\n";
    $att_message.="Content-Transfer-Encoding: 7bit\r\n\r\n";
    $att_message.=$message."\r\n\r\n";

    $att_check=preg_split('/,/',$attachment_fields);
    $att_run=sizeof($att_check);
    for($i=0;$i<$att_run;$i++)
    {
    $fileatt=$_FILES[$att_check[$i]]['tmp_name'];
    $fileatt_name=$_FILES[$att_check[$i]]['name'];
    $fileatt_type=$_FILES[$att_check[$i]]['type'];
    if (is_uploaded_file($fileatt))
    {
    $file=fopen($fileatt,'rb'
    $data=fread($file,filesize($fileatt));
    fclose($file);
    $data=chunk_split(base64_encode($data));
    $att_message.="--{$border}\n";
    $att_message.="Content-Type: {$fileatt_type}; name=\"{$fileatt_name}\"\r\n";
    $att_message.="Content-Disposition: attachment; filename=\"{$fileatt_name}\"\r\n";
    $att_message.="Content-Transfer-Encoding: base64\r\n\r\n".$data."\r\n\r\n";
    }
    }
    $att_message.="--{$border}--\n";
    return $att_message;
    }
    // function to set content type
    function contentType($charset, $format)
    {
    if($format=="vert_table")
    $content_type="Content-type: text/html; charset=\"".$charset."\"\r\n";
    else if($format=="horz_table")
    $content_type="Content-type: text/html; charset=\"".$charset."\"\r\n";
    else
    $content_type="Content-type: text/plain; charset=\"".$charset."\"\r\n";
    return $content_type;
    }
    // header injection filter
    function headerInjectionFilter($reply_to_field, $reply_to_name, $header_injection_regex)
    {
    $security_filter="";
    if(strlen($reply_to_field) > 0)
    {
    if(eregi($header_injection_regex,$reply_to_field))
    $security_filter.="<li>Header injection attempt detected in 'email' data, mail aborted.</li>\n";
    if(eregi($header_injection_regex,$reply_to_name))
    $security_filter.="<li>Header injection attempt detected in 'name' data, mail aborted.</li>\n";
    }
    return $security_filter;
    }
    //////////////////////////
    // end global functions //
    //////////////////////////

    ////////////////////////////////
    // begin procedural scripting //
    ////////////////////////////////
    $domain_chk=checkReferer();
    if($domain_chk=="yes")
    {
    $security_filter=headerInjectionFilter($_POST[$reply_to_field[$config]], $_POST[$reply_to_name[$config]], $header_injection_regex);
    $error_message=checkFields($required_fields[$config], $required_email_fields[$config], $regex);
    if(strlen($error_message) < 1 && strlen($security_filter) < 1)
    {
    // build appropriate message format for recipient
    $content_type=contentType($charset[$config], $mail_type[$config]);
    $message=buildTable($mail_type[$config], $mail_fields[$config], $mail_intro[$config], "recipient", $return_ip[$config]);
    // build header data for recipient message
    $extra="From: ".$_POST[$reply_to_name[$config]]."<".$_POST[$reply_to_field[$config]].">\r\n";
    if($cc_tomail[$config]!="")
    $extra.="Cc: ".$cc_tomail[$config]."\r\n";
    if($bcc_tomail[$config]!="")
    $extra.="Bcc: ".$bcc_tomail[$config]."\r\n";
    $extra.="X-Priority: ".$mail_priority[$config]."\r\n";
    // get attachments if necessary
    if($attachment_fields[$config]!="")
    {
    $semi_rand=md5(time());
    $border="==Multipart_Boundary_x{$semi_rand}x";
    $extra.="MIME-Version: 1.0\r\n";
    $extra.="Content-Type: multipart/mixed; boundary=\"{$border}\"";
    $message=getAttachments($attachment_fields[$config], $message, $content_type, $border);
    }
    else
    {
    $extra.="MIME-Version: 1.0\r\n".$content_type;
    }
    // send recipient email
    if($debug==1)
    echo "<p>Mail would have sent if not in debug mode.</p>";
    else if($debug==0)
    mail("".$tomail[$config]."", "".stripslashes($subject[$config])."", "".stripslashes($message)."", "$extra");
    // autoresponse email if necessary
    if($send_copy[$config]=="yes")
    {
    // build appropriate message format for autoresponse
    $content_type=contentType($charset[$config], $send_copy_format[$config]);
    $message=buildTable($send_copy_format[$config], $send_copy_fields[$config], $copy_intro[$config], "autoresponder", $return_ip[$config]);
    // build header data for autoresponse
    $copy_tomail=$_POST[$copy_tomail_field];
    $copy_extra="From: ".$copy_from[$config]."\r\n";
    // get autoresponse attachments if necessary
    if($send_copy_attachment_fields[$config]!="")
    {
    $semi_rand=md5(time());
    $border="==Multipart_Boundary_x{$semi_rand}x";
    $copy_extra.="MIME-Version: 1.0\r\n";
    $copy_extra.="Content-Type: multipart/mixed; boundary=\"{$border}\"";
    $message=getAttachments($send_copy_attachment_fiel ds[$config], $message, $content_type, $border);
    }
    else
    {
    $copy_extra.="MIME-Version: 1.0\r\n".$content_type;
    }
    // send autoresponse email
    $send_copy = 1;
    if($copy_tomail=="" || !eregi($email_regex,$copy_tomail))
    $send_copy = 0;
    if($send_copy == 1)
    mail("$copy_tomail", "".$copy_subject[$config]."", "$message", "$copy_extra");
    }
    // showing thanks pages from a successful submission
    if($thanks_page[$config]=="")
    {
    echo "<p>".$thanks_page_title[$config]."</p>\n";
    echo "<p>".$thanks_page_text[$config]."</p>\n";
    }
    else
    {
    header("Location: ".$thanks_page[$config]);
    }
    }
    else
    {
    // entering error page options from missing required fields
    if($error_page[$config]=="")
    {
    echo "<p>".$error_page_title[$config]."</p>\n";
    echo "<ul>\n";
    echo $security_filter;
    echo $error_message;
    echo "</ul>\n";
    echo "<p>".$error_page_text[$config]."</p>\n";
    }
    else
    {
    header("Location: ".$error_page[$config]);
    }
    }
    }
    else
    {
    // message if unauthorized domain trigger from referer checking option
    echo "<p>Sorry, mailing request came from an unauthorized domain.</p>\n";
    }
    //////////////////////////////
    // end procedural scripting //
    //////////////////////////////

    }
    else
    {
    echo "<p>Error</p>";
    echo "<p>No form data has been sent to the script</p>\n";
    }
    if($footer[$config]!="")
    include($footer[$config]);
    ob_end_flush();
    ?>
    A única parte que você deve mexer é no topo do script.

    Ae na página de contato:
    <form id="form" method="post" action="formmailer.php">
    <input type="text" name="Nome" value=""/>
    <input type="text" name="Email" value="" />
    <input type="text" name="Empresa" value="" />
    <input type="text" name="Telefone" value="" />
    <input type="reset" name="Reset" value="Apagar" />
    <input type="submit" name="submit" value="Enviar" />
    <input type="hidden" name="config" value="0" />
    Ae você muda pros campos que você precisar.

  8. #8
    rocksul
    Guest

    Re: Ajuda em PHP - Iniciante

    Citação Postado originalmente por RGBguima Ver Post
    Então Manda Debugar suas variaveis...

    As vezes tu não esta "pegando" ela corretamente!
    Achei o pobrema!
    Achei a puerra de la mierda!
    Eu ia me matar fuçando nessa erva e nunca ia achar o pobrema de buesta!
    ***'S dos caras ervador da plugue in!

    Taki ó!
    O header da mensagem deles TEM QUE SER ESSE
    [hr]
    $headers = "De onde o email sai <[email protected]";
    $headers .= "X-Mailer: PHP4\n";
    $headers .= "X-Priority: 3\n";
    $headers .= "MIME-Version: 1.0\n";
    $headers .= "Content-Type: text/html;boundary=\"==MIME_BOUNDRY_alt_main_message\"\ n\n";
    [hr]
    Vlw pelo exemplo amigo! Mas agora já consegui!!!!!!!!!!!!!

    Mas no servidor da plugue in tb não ia dar! Pq no teu ta assim e no da plugue in é assado, como tá ali em cima. O que os caras não fazem pra complicar quem tá começando!!!!!!!!!!!

    $extra.="MIME-Version: 1.0\r\n";
    $extra.="Content-Type: multipart/mixed; boundary=\"{$border}\"";
    $extra.="Bcc: ".$bcc_tomail[$config]."\r\n";
    $extra.="X-Priority: ".$mail_priority[$config]."\r\n";


  9. #9
    Motociclista experiente Avatar de superkyo
    Data de Ingresso
    Apr 2007
    Localização
    SOROCABA-SP
    Idade
    37
    Posts
    2.327

    Re: Ajuda em PHP - Iniciante

    Eu nada entendi !! conversação mto complexa...
    ** 6 anos de CNH A/B **
    - Nenhuma multa
    - 2 quedas

    SUZUKI YES 2007
    [EM BREVE CRIAREI NOVO TÓPICO DA MOTOCA]
    Quilometragem : 23.500km
    Média de consumo atual :37.5 km/l

  10. #10
    rocksul
    Guest

    Re: Ajuda em PHP - Iniciante

    ÓLHA AÍ
    Já bastava ser minha primeira vez no PHP e esses ervas ainda complicam minha vida. Assim não dá né!

 

 

Tópicos Similares

  1. Iniciante CB300
    Por leandroaguiar no fórum Área de debate
    Respostas: 23
    Último Post: 13-09-10, 18:33
  2. Iniciante com dúvida
    Por Luuiis no fórum Área de debate
    Respostas: 13
    Último Post: 15-08-10, 16:18
  3. Iniciante
    Por hurz no fórum Área de debate
    Respostas: 17
    Último Post: 02-08-10, 19:45
  4. Iniciante, moto adequada?
    Por tgcardoso no fórum Área de debate
    Respostas: 8
    Último Post: 08-10-09, 17:41
  5. Iniciante no Wheeling...
    Por G3si3l no fórum Área de debate
    Respostas: 16
    Último Post: 03-07-08, 12:02

Permissões de Postagem

  • Você não pode iniciar novos tópicos
  • Você não pode enviar respostas
  • Você não pode enviar anexos
  • Você não pode editar suas mensagens
  •