
arnaldoydas
Membros-
Total de itens
4 -
Registro em
-
Última visita
Sobre arnaldoydas

arnaldoydas's Achievements
0
Reputação
-
bom dia Amigos! Tenho um sistema em php que cadastra e-mails num arquivo .txt. Até aí tudo Ok! Funciona bem, mas não consigo validar o e-mail em hipótese alguma, tentei de tudo, mas não manjo nada de php, ainda sou novato. Já tentei $email = 'teste@meusite.com'; if(filter_var($email, FILTER_VALIDATE_EMAIL)){ echo 'E-mail válido'; }else{ echo 'E-mail invalido'; } E também function validaEmail($mail){ if(preg_match("/^([[:alnum:]_.-]){3,}@([[:lower:][:digit:]_.-]{3,})(\.[[:lower:]]{2,3})(\.[[:lower:]]{2})?$/", $mail)) { return true; }else{ return false; } } Além disso, não consigo fazer o e-mail de confirmação funcionar quando digito o e-mail no input. Alguém poderia me dar uma luz? Valeu! Postei o código abaixo: <?php /* Verifica qual é o sistema operacional do servidor para ajustar o cabeçalho de forma correta. */ if(PATH_SEPARATOR == ";") $quebra_linha = "\r\n"; //Se for Windows else $quebra_linha = "\n"; //Se "não for Windows" ######################################################################## # Global Settings... ######################################################################## # Set the password for the eMail List editor! $pass="secret"; # Name of the datafile $filelocation="subscribers.txt"; # Title of the newsletter, will be displayed in the FROM field of the mailclient $lettername="eu@meudominio.com.br"; # Your email, will be the reply-to mail $youremail="eu@meudominio.com.br"; ######################################################################## # Displayed Messages ######################################################################## # Welcome message displayed above the form for subscribing/unsubscribing $welcomemessage = "Gostaria de receber nosso Informativo?"; # Sorrymessage for failed subscription, will be followed by the email! $sorrysignmessage = "Desculpe, já existe em nosso cadastro o e-mail "; # Subscribe message, will be displayed when subscribing $subscribemessage = "Obrigado por se cadastrar, um e-mail de confirmação foi enviado para "; # Subscribemail, will be sent when someone subscribes. $subscribemail = "Obrigado por se cadastrar em nosso Informativo"; # Unsubscribemessage for deletion, will be followed by the email! $unsubscribemessage = "Foi apagado de nosso sistema o e-mail "; # Unsubscribemessage for failed deletion, will be followed by the email! $failedunsubscriptionmessage = "Desculpe, não consta em nosso banco de dados o e-mail "; ######################################################################## # Let the code begin... ######################################################################## # Checks if the file exists, if not creates a new one if (!file_exists($filelocation)) { $newfile = fopen($filelocation,"w+"); fclose($newfile); } # Open the datafile and read the content $newfile = fopen($filelocation,"r"); $content = fread($newfile, filesize($filelocation)); fclose($newfile); # Remove the slashes PHP automatically puts before special characters $content=stripslashes($content); # Reset the output of the "search result" $out=""; # Put the entries into the array lines $lines = explode("%",$content); for ($key=1;$key<sizeof($lines);$key++){ # when the email is not in the list, add the old entries if ($lines[$key] != $email){ $out .= "%".$lines[$key]; } # when it's already in the list, set found else { $found=1; } } ######################################################################## # Signing in ######################################################################## if ($action=="sign"){ # When there is already a subscription for this email *duh* if ($found==1){ # Display Sorrymessage echo "<div align=\"left\">".$sorrysignmessage.$email."</div><br/>"; $disp="yes"; } # otherwise, add the email to the list else { $disp="no"; $newfile = fopen($filelocation,"a+"); $add = "%".$email; fwrite($newfile, $add); fclose($newfile); # display the message of subscription echo "<div align=\"left\">".$subscribemessage.$email."</div><br/>"; # send confirmation Mail $submailheaders = "From: $lettername subscription form"; $submailheaders .= "Reply-To: $youremail"; mail ($email,$lettername." subscription",$subscribemail,$submailheaders); } } ######################################################################## # Signing out ######################################################################## if ($action=="delete"){ $disp="no"; # If the email is in the list... if ($found == 1){ $newfile = fopen($filelocation,"w+"); fwrite($newfile, $out); fclose($newfile); # display the message for deleted items... echo "<div align=\"left\">".$unsubscribemessage.$email."</div><br/>"; $disp="no"; } # if the email is not in the list if ($found != 1){ # display the message that tells that... echo "<div align=\"left\">".$failedunsubscriptionmessage.$email."</div><br/>"; $disp="yes"; } } ######################################################################## # The core for the owner of the letter ######################################################################## if ($pw == $pass){ # When nothing was entered so far, display the form if ($send != "yes" && $send != "test"){ print'<form method="post"><input type="hidden" name=pw value='.$pass.'><input type="hidden" name=send value=yes> Cadastro de Informativo:</b><br/> Assunto:<br/> <input type="text" name="subject" size=20><br/> Mensagem:<br/> <textarea cols=50 rows=10 wrap="virtual" name="message"></textarea><br/> <input type="submit" value="send"> </form>'; } # Predefine the Mail Settings for sending... $mailheaders = "From: $lettername"; $mailheaders .= "Reply-To:$youremail"; # add data in bcc fields # Data was ok, send button is pressed if ($send == "yes"){ $message=stripslashes($message); $subject=stripslashes($subject); $lines = explode("%",$content); for ($key=1;$key<sizeof($lines);$key++){ mail ($lines[$key],$subject,$message,$mailheaders); } print "O seguinte e-mail foi enviado!"; print "<pre>$mailheaders\n$subject\n$message</pre>"; } } ######################################################################## # The Form for the users... ######################################################################## if ($pw != $pass && $disp != "no"){ print $welcomemessage; print' <div align="left"><form method="post"> <input type="text" name="email" size=30> <input type="radio" name="action" value="sign" checked="checked">cadastrar <input type="radio" name="action" value="delete">cancelar<br> <input type="submit" value="send"> </form></div> '; } ?>
-
Formulário PHP incompleto. alguém pode me ajudar?
pergunta respondeu ao arnaldoydas de arnaldoydas em PHP
poxa amigo, falou grego! desculpa, mas não sei o que é uma função mail... :wacko: sou leigo, estou iniciando no php, mas mesmo assim obrigado pela iniciativa! MLeandroJr!, o que o amigo quis dizer é que no trecho onde você envia o email, você deve colocar mais uma função 'mail($remetente, $assunto, $mensagem, $headers);' logo após a linha que você envia ao destinatário, para que você receba uma cópia do email. Obs.: O remetente e o destinatário estão puxando o mesma variável! $emailremetente = $_POST['email']; $emaildestinatario = $_POST['email']; Sou novo aqui no fórum, mas qualquer dúvida, posta aí! ^_^ Muuuuuuito obrigado, MuRd0C Resolveu o problema em poucas palavras, parabéns! Você está no caminho certo! Abs. -
Formulário PHP incompleto. alguém pode me ajudar?
pergunta respondeu ao arnaldoydas de arnaldoydas em PHP
poxa amigo, falou grego! desculpa, mas não sei o que é uma função mail... :wacko: sou leigo, estou iniciando no php, mas mesmo assim obrigado pela iniciativa! -
amigos, tenho um formulário em PHP que funciona em partes, ele envia uma cópia pro remetente mas pra mim a mensagem não chega. Já tentei de tudo, tenho fuçado à uma semana e nada, só me descabelei. Abaixo disponibilzo o código. Desde já agradeço! <?php /* Verifica qual éo sistema operacional do servidor para ajustar o cabeçalho de forma correta. */ if(PATH_SEPARATOR == ";") $quebra_linha = "\r\n"; //Se for Windows else $quebra_linha = "\n"; //Se "não for Windows" // Passando os dados obtidos pelo formulário para as variáveis abaixo $nomeremetente = $_POST['nome']; $emailremetente = $_POST['email']; $emaildestinatario = $_POST['email']; $telefoneremetente = $_POST['telefone']; $assunto = $_POST['assunto']; $mensagem = $_POST['mensagem']; $emailmktremetente = $_POST['emailmkt']; /* Montando a mensagem a ser enviada no corpo do e-mail. */ $mensagemHTML = '<P>Obrigado! A mensagem foi enviada para o setor de '.$assunto.'</P> <P>Abaixo está a cópia de sua mensagem:</P> <p>Nome: <b><i>'.$nomeremetente.'</i></b></p> <p>E–mail <b><i>'.$emaildestinatario.'</i></b></p> <p>Telefone: <b><i>'.$telefoneremetente.'</i></b></p> <p>Mensagem: <b><i>'.$mensagem.'</i></b></p> <p>E–mail Marketing: <b><i>'.$emailmktremetente.'</i></b></p> <hr>'; /* Montando o cabeçalho da mensagem */ $headers = "MIME-Version: 1.1" .$quebra_linha; $headers .= "Content-type: text/html; charset=UTF-8" .$quebra_linha; // Perceba que a linha acima contém "text/html", sem essa linha, a mensagem não chegará formatada. $headers .= "From: " . $emailsender.$quebra_linha; $headers .= "Reply-To: " . $emailsender . $quebra_linha; // Note que o e-mail do remetente será usado no campo Reply-To (Responder Para) /* Enviando a mensagem */ //É obrigatório o uso do parâmetro -r (concatenação do "From na linha de envio"), aqui na Locaweb: if(!mail($emaildestinatario, $assunto, $mensagemHTML, $headers ,"-r".$emailsender)){ // Se for Postfix $headers .= "Return-Path: " . $emailsender . $quebra_linha; // Se "não for Postfix" mail($emaildestinatario, $assunto, $mensagemHTML, $headers); } /* Mostrando na tela as informações enviadas por e-mail */ echo "Sua mensagem sobre $assunto foi enviada com sucesso!"; echo "<meta http-equiv='refresh' content='0;url=http://www.blabla.com.br/faleconosco'>"; ?>