Hi i create a php form in my WP page but when i try to submit the information i get the error “Object not found”. Both the php and html are on the same file page-contact-us.php
I appreciate the answers
<?php
if (isset($_POST['submit'])){
$to='########################';
$subject = 'nova mensagem';
$name = $_POST['f_name'];
$company = $_POST['f_company'];
$role = $_POST['f_role'];
$email = $_POST['f_email'];
$subject = $_POST['f_subject'];
$message = $_POST['f_message'];
$human = intval($_POST['f_human']);
$from = 'form de comentários';
$body = "De: $namen Empresa: $companyn Cargo: $rolen Assunto: $subjectn Message:n $message";
if (isset($_POST['f_name'])) {
$errName = 'Por favor indique o seu nome';}
if (!$_POST['f_email'] || !filter_var($_POST['f_email'], FILTER_VALIDATE_EMAIL)) {
$errEmail = 'Indique um email valido';}
if (!$_POST['f_subject']) {
$errSubject = 'Indique um assunto valido';}
if (!$_POST['f_message']){
$errMessage = 'Indiquem um comentário';}
if ($human !== 5) {
$errHuman = 'A sua conta está errada :)';}
if (!$errName && !$errEmail && !$errMessage && !$errHuman) {
if (mail ($to, $subject, $from)) {
$result='<div class="alert alert-success">Obrigado!</div>';
}
else {
$result='<div class="alert alert-danger">Ocorreu um erro tente mais tarde</div>';
}
}
}?>
Form
<form class='form-horizontal' role='form' method='POST' action='page-contact-us.php'>
<div class="form-group">
<div class="col-sm-10">
<input type="text" class="form-control" id="f_name" name="f_name" placeholder="Nome" value="">
<?php if (!empty($errName)) { ?>
<?php echo "<p class='text-danger'>$errName</p>";?>
<?php } ?>
</div>
</div>
<div class="form-group">
<div class="col-sm-10">
<input type="text" class="form-control" id="f_company" name="f_company" placeholder="Empresa" value="">
</div>
</div>
<div class="form-group">
<div class="col-sm-10">
<input type="text" class="form-control" id="f_role" name="f_role" placeholder="Cargo" value="">
</div>
</div>
<div class="form-group">
<div class="col-sm-10">
<input type="email" class="form-control" id="f_email" name="f_email" placeholder="exemplo@dominio.com" value="">
<?php if(!empty($errEmail)) { ?>
<?php echo "<p class='text-danger'>$errEmail</p>";?>
<?php } ?>
</div>
</div>
<div class="form-group">
<div class="col-sm-10">
<input type="text" class="form-control" id="f_subject" name="f_Subject" placeholder="Assunto" value="">
<?php if(!empty($errSubject)) { ?>
<?php echo "<p class='text-danger'>$errSubject</p>";?>
<?php } ?>
</div>
</div>
<div class="form-group">
<div class="col-sm-10">
<textarea class="form-control" rows="4" name="f_message" placeholder="Insira um comentario"></textarea>
<?php if(!empty($errMessage)) { ?>
<?php echo "<p class='text-danger'>$errMessage</p>";?>
<?php } ?>
</div>
</div>
<div class="form-group">
<label for="human" class="col-sm-2 control-label">2 + 3 = ?</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="f_human" name="f_human" placeholder="Sua resposta">
<?php if(!empty($errHuman)) { ?>
<?php echo "<p class='text-danger'>$errHuman</p>";?>
<?php } ?>
</div>
</div>
<div class="form-group">
<div class="col-sm-10 col-sm-offset-2">
<input id="submit" name="submit" type="submit" value="Enviar" class="btn btn-primary">
</div>
</div>
<div class="form-group">
<div class="col-sm-10 col-sm-offset-2">
<?php if (!empty($result)) { ?>
<?php echo $result; ?>
<?php } ?>
</div>
</div>
Change code to