Skip to content

Instantly share code, notes, and snippets.

@pingpoli
Last active June 3, 2022 15:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pingpoli/617f1a5f2128bd95dcf5c1fb0fc085cc to your computer and use it in GitHub Desktop.
Save pingpoli/617f1a5f2128bd95dcf5c1fb0fc085cc to your computer and use it in GitHub Desktop.
<?php
// CAPTCHA
// create two random values between 0 and 1
$xPos = (float)rand()/(float)getrandmax();
$yPos = (float)rand()/(float)getrandmax();
$_SESSION['captcha_x'] = $xPos;
$_SESSION['captcha_y'] = $yPos;
?>
<script src="/js/pingpoliSliderCaptcha.js"></script>
<script>
function onSubmit()
{
var captcha = new pingpoliSliderCaptcha();
captcha.onsuccess = () => {
document.getElementById("xPos").value = <?php echo $xPos; ?>;
document.getElementById("yPos").value = <?php echo $yPos; ?>;
document.getElementById("contactForm").submit();
};
captcha.show( <?php echo $xPos; ?> , <?php echo $yPos; ?> );
return false;
}
</script>
<form action="contact.php" method="POST" id="contactForm" onsubmit="return onSubmit()">
<input type="email" name="email" id="email" maxlength="256" placeholder="Your Email" required><br><br>
<textarea name="text" id="text" required></textarea><br><br>
<input type="hidden" id="xPos" name="xPos" value="-1">
<input type="hidden" id="yPos" name="yPos" value="-1">
<button>Send</button>
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment