0
hello! I have a problem with my contact form. The PHP that processes the data and sends it to my email, returns the "From" field with my server user address and not as the sender address.
<?php
if(isset($_POST['contact_name']) != ""){
$to = "[email protected]";
$from = $_POST["contact_email"];
$message = " <strong>Nome: </strong>".$_POST["contact_name"]."<br />";
$message .= " <strong>Email: </strong>".$_POST["contact_email"]."<br />";
$message .= " <strong>Telefone: </strong>".$_POST["contact_phone"]."<br />";
$message .= " <strong>Cotacao para: </strong>".$_POST["contact_servico"]."<br />";
$message .= " <strong>Mensagem: </strong>".$_POST["message"]."<br />";
$subject = 'Solicitação de cotação';
$headers = "De: ".$_POST["contact_email"]."\n";
$headers .= "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$send = mail($to,$subject,$message,$headers);
if($send)
{
echo "Agradecemos sua solicitação. Entraremos em contato o mais breve possível.";
}
else
{
echo "Erro no envio da mensagem. Por favor, verifique os campos de preenchimento.";
}
}
if(isset($_POST['subscribe_name']) != ""){
$to = "[email protected]";
$from = $_POST["subscribe_email"];
$message = " <strong>Nome: </strong>".$_POST["subscribe_name"]."<br />";
$message .= " <strong>Email: </strong>".$_POST["subscribe_email"]."<br />";
$subject = 'Inscrição';
$headers = "De: ".$_POST["subscribe_email"]."\n";
$headers .= "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$send = mail($to,$subject,$message,$headers);
if($send)
{
echo "Agradecemos sua solicitação.";
}
else
{
echo "error";
}
}
?>
<form class="contact-form" name="contact_form" id="contact_form" method="post" action="process.php" onSubmit="return false">
<div class="row">
<div class="col-md-6">
<input type="text" data-delay="300" placeholder="Seu nome" name="contact_name" id="contact_name" class="input">
</div>
<div class="col-md-6">
<input type="text" data-delay="300" placeholder="Seu E-mail" name="contact_email" id="contact_email" class="input">
</div>
</div>
<div class="row">
<div class="col-md-6">
<input type="text" data-delay="300" placeholder="Seu telefone" name="contact_phone" id="contact_phone" class="input">
</div>
<div class="col-md-6">
<input type="text" data-delay="300" placeholder="Cotacao para" name="contact_servico" id="contact_servico" class="input">
</div>
</div>
<textarea data-delay="500" class="required valid" placeholder="Mensagem" name="message" id="message"></textarea>
<button class="btn btn-primary" name="" type="submit" data-text="Enviar" onClick="validateContact();">Enviar</button>
</form>
Take a look at the "name" property of the inputs, maybe it’s the other way around.
– Cobra