Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
// 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>
function onSubmit()
var captcha = new pingpoliSliderCaptcha();
captcha.onsuccess = () => {
document.getElementById("xPos").value = <?php echo $xPos; ?>;
document.getElementById("yPos").value = <?php echo $yPos; ?>;
}; <?php echo $xPos; ?> , <?php echo $yPos; ?> );
return false;
<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">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment