In a earlier question I got an answer from @ADyson of how to get the returns on a new blank page and that is in a way a solution, and thanks a lot for that. But I would prefer to get it under the contact form on that spesific contact page.I was told to do it with echo statement and if statement, but I am not smart enough to manage that. I use a web builder in the web host one.com. I enter the contact form in a code box on the contact page (I can not do corrections in the html-codes because it is over written next time I publish something with the web builder) an the php-file in the root of the file manager. I added echo statements to the returns in php, as you told me, and now the returns shows up on a blank page.That was my first goal, but as I said I would prefer to get it under the contact form.
Here is my form.php:
<?php
if(isset($_POST['submit']) && !empty($_POST['submit'])):
if(isset($_POST['g-recaptcha-response']) && !empty($_POST['g-recaptcha-response'])):
//your site secret key
$secret = 'secret key';
//get verify response data
$verifyResponse = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret='.$secret.'&response='.$_POST['g-recaptcha-response']);
$responseData = json_decode($verifyResponse);
if($responseData->success):
//contact form submission code
$name = !empty($_POST['name'])?$_POST['name']:'';
$email = !empty($_POST['email'])?$_POST['email']:'';
$message = !empty($_POST['message'])?$_POST['message']:'';
$to = 'kontakt@boakustikk.no';
$subject = 'New contact form have been submitted';
$htmlContent = "
<h1>Henvendelse fra din hjemmeside</h1>
<p><b>Navn: </b>".$name."</p>
<p><b>E-post: </b>".$email."</p>
<p><b>Melding: </b>".$message."</p>
";
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "
";
$headers .= "Content-type:text/html;charset=UTF-8" . "
";
// More headers
$headers .= 'From:'.$name.' <'.$email.'>' . "
";
//send email
@mail($to,$subject,$htmlContent,$headers);
echo$succMsg = 'TAKK FOR MELDING. VI KONTAKTER DEG SNAREST.';
else:
echo$errMsg = 'ROBOT VERIFIKASJON GIKK GALT, GÅ TILBAKE OG PRØV PÅ NYTT.';
endif;
else:
echo$errMsg = 'MELDINGEN BLE IKKE SENDT. VENNLIGST GÅ TILBAKE OG KLIKK PÅ reCAPTCHA BOKS.';
endif;
else:
echo$errMsg = '';
echo$succMsg = '';
endif;
?>
and here is my form.html:
<form action="form.php" method="POST">
<input type="text" name="name" placeholder="Ditt navn" size="43" /><br><br>
<input type="text" name="email" placeholder="Din E-post" size="43" /><br><br>
<textarea type="text" name="message" rows="8" cols="41"></textarea><br><br>
<div class="g-recaptcha" data-sitekey="site key"></div><br>
<input type="submit" name="submit" value= "SEND MELDING">
</form>
I will be very happy to fix this issue.
BR Hans Kristian
</div>