Is it possible to display the echo content which is HTML on my website after I press on my button (type submit), the POST
request is made on the same site.
When I press on my button it's refreshing the website and making the POST
request but I don't want that it's automatically refreshing the site, I want to display the alert on the current site if possible.
<button id="submit" type="submit" class="btn btn-darkred rounded mr-xl-5" style="width:300px">LOGIN</button>
This is the PHP code
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$secretKey = 'captchaSecret';
$captcha = $_POST['g-recaptcha-response'];
if(!$captcha){
echo '<p class="alert alert-warning">Please check the the captcha form.</p>';
exit;
}
$ip = $_SERVER['REMOTE_ADDR'];
$response=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$secretKey."&response=".$captcha."&remoteip=".$ip);
$responseKeys = json_decode($response,true);
if(intval($responseKeys["success"]) !== 1) {
echo '<p class="alert alert-warning">Please check the the captcha form.</p>';
} else {
echo 'successful';
}
}
?>
This is what I want to be displayed on the current site & not a blank page with the alert:
echo '<p class="alert alert-warning">Please check the the captcha form.</p>';