Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?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