1
I am sending, through a form, an email. I do the tests, but it receives only 3 of the 4 fields, it is simply as if the field with the name
and con_phone
did not exist.
HTML:
<form class="contact-form top_60" method="POST" action="mail.php">
<div class="row">
<!--Name-->
<div class="col-md-6">
<input id="con_name" name="con_name" class="form-inp requie" type="text" placeholder="Nome">
</div>
<!--Email-->
<div class="col-md-6">
<input id="con_email" name="con_email" class="form-inp requie" type="text" placeholder="Email">
</div>
<!--Telefone-->
<div class="col-md-6">
<input id="con_telefone" name="con_telefone" class="form-inp requie" type="text" placeholder="Telefone">
</div>
<div class="col-md-12">
<!--Message-->
<textarea name="con_message" id="con_message" class="requie" placeholder="Como podemos ajudá-lo?" rows="8"></textarea>
<button id="con_submit" class="sitebtn top_30" type="submit">Enviar</button>
</div>
</div>
</form>
PHP:
<?php
//require 'PHPMailerAutoload.php';
require 'phpmailer/class.phpmailer.php';
$mail = new PHPMailer;
$con_name = $_POST['con_name'];
$con_email = $_POST['con_email'];
$con_telefone = $_POST['con_telefone'];
$con_message = $_POST['con_message'];
$mail->setFrom($con_email, $con_name);
//$mail->addAddress('[email protected]', 'Oficina da Criação');
$mail->addAddress('[email protected]', 'Oficina da Criação');
$mail->Subject = 'E-mail enviado pelo contato do site.';
$mail->Body = '
Nome: ' . $con_name . '
Email: ' . $con_email . '
Telefone: ' . $con_telefone . '
Mensagem:
' . $con_message . '
Post: ' . json_encode($_POST) . '
Mensagem enviada no dia ' . date("d/m/Y") . ' às ' . date("G:i") . '
IP do usuário: ' . $_SERVER["REMOTE_ADDR"];
if(!$mail->send()) {
echo 'Message was not sent.';
echo 'Mailer error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent.';
}
?>
In the email I received this way:
Nome: Jakson Juliano Fischer
Email: [email protected]
Telefone:
Mensagem:
a1s2d1a2s1d
Post: {"con_name":"Jakson Juliano Fischer","con_email":"[email protected]","con_message":"a1s2d1a2s1d"}
Mensagem enviada no dia 10/05/2019 às 13:56
IP do usuário: 000.002.125.75
Someone’s been through this trouble and can help me?
Hi, modifies class="form-Inp requie" to class="form-Inp require" and in the part of the code that receives the POST method modifies $con_name = $_POST['con_name']; to $con_phone= Trim(addslashes($_POST['con_phone']);, does this for others, and tries to send, may be because you are not treating the variables that receive the POST method, and sending straight, is breaking.
– ElvisP
See what returns giving a var_dump:
var_dump($_POST);
– Victor Carnaval
Unfortunately, I tried to do it the way @Eliseub did. menciou, but it didn’t work, in relation to the var_dump cited by Victor, results in the same thing that json_decode ($POST) returned... It’s like there’s no field with the name com_phone :(
– Jakson Fischer
Ola @Jaksonfischer, Do not change the question title to indicate that your problem has been solved. If you have found a different response from the proposals by the community consider answering your own question, but later you may accept it, it may help people with the same problem =D -- I can answer my own question? -- If any community response helped you consider accepting, this would be the best way to thank. = D -- [Tour]
– Icaro Martins
@Icaromartins thanks for the touch, I will make the necessary changes to meet the rules :D
– Jakson Fischer