Jump to content
Fórum Script Brasil
  • 0

Formulario de Email (não envia dados)



Ola tudo bom... estou com esse pepino leve rs... o formulario não envia o campo "TELEFONE" apenas o restante vai normalmente"

<form method="post" action="sendmail.php">

            <p><label for="name">Name:*</label> <input type="text" class="form-control" name="name" id="name" tabindex="1" /></p>
            <p><label for="email">Email:*</label> <input type="text" class="form-control" name="email" id="email" tabindex="2" /></p>
            <p><label for="phone">Telefone:*</label> <input type="text" class="form-control" name="phone" id="phone" tabindex="3" /></p>
            <p><label for="comments">Mensagem:*</label> <textarea  class="form-control" name="comments" id="comments" cols="12" rows="6" tabindex="4"></textarea></p>
            <p><input name="enviar" type="submit" id="submit" class="submit" value="Enviar" tabindex="5" /></p>




	$name = $_POST['name'];
	$email = filter_var($_POST['email'], FILTER_SANITIZE_EMAIL);
	$phone = $_POST['phone'];
	$comments = filter_var($_POST['comments'], FILTER_SANITIZE_STRING);

	$site_owners_email = '[email protected]'; 
	$site_owners_name = 'Contato Site'; 

	if (!preg_match('/^[a-z0-9&\'\.\-_\+][email protected][a-z0-9\-]+\.([a-z0-9\-]+\.)*+[a-z]{2}/is', $email)) {
		$error['email'] = "Por Favor digite um endereço de email valido";

	if (strlen($comments) < 3) {
		$error['comments'] = "Por favor deixe uma mensagem.";

	if (!$error) {

		$mail = new PHPMailer();

		$mail->From = $email;
		$mail->FromName = $name;
		$mail->Subject = "Contato Site";
		$mail->AddAddress($site_owners_email, $site_owners_name);
		$mail->Body = '<b>Nome:</b> '. $name .'<br/><b>E-mail:</b> '. $email .'</br><b>Telefone:</b> '. $phone .'<br/><br/><b>Mensagem:</b> ' . $comments;


		echo "<div class='alert alert-success'  role='alert'>Obrigado " . $name . ". Sua mensagem foi enviada!</div>";

	} # end if no error
	else {

		$response = (isset($error['name'])) ? "<div class='alert alert-danger'  role='alert'>" . $error['name'] . "</div> \n" : null;
		$response .= (isset($error['email'])) ? "<div class='alert alert-danger'  role='alert'>" . $error['email'] . "</div> \n" : null;
		$response .= (isset($error['phone'])) ? "<div class='alert alert-danger'  role='alert'>" . $error['phone'] . "</div> \n" : null;
		$response .= (isset($error['comments'])) ? "<div class='alert alert-danger'  role='alert'>" . $error['comments'] . "</div>" : null;

		echo $response;
	} # end if there was an error sending


Alguém sabe me dizer se tem algum erro ou outro caminho que eu possa melhorar?


Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Forum Statistics

    • Total Topics
    • Total Posts
  • Create New...