Skip to content

Lightweight PHP slider captcha — no dependencies, secure (token, expiry, honeypot, attempt limit), shows match % after verification.

License

Notifications You must be signed in to change notification settings

DigitalEforce/php-slider-captcha

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP Slider Captcha

A simple and secure slider captcha built with PHP + JavaScript to protect forms from bots and spam.
This captcha requires users to slide a block into place and verifies how closely it matches the target (with a percentage).


✨ Features

  • A lightweight, dependency-free PHP slider captcha that enhances form security with:

    ✅ Match percentage feedback after verification
    🔒 CSRF-like token protection
    ⏳ 2-minute expiry
    🕵️ Honeypot field (bot trap)
    🚫 Attempt limit per session
    ⚡ Easy drop-in integration for any PHP form


📂 Repository Structure

php-slider-captcha/
│── nvcaptcha/
│   ├── captcha_init.php     # Initializes captcha session & security
│   ├── captcha_view.php     # Captcha UI (slider)
│   ├── captcha_verify.php   # Backend verification (AJAX)
│── example.php              # Example usage form
│── README.md                # Documentation

🚀 Installation

  1. Clone the repository:
    git clone https://github.com/DigitalEforce/php-slider-captcha.git
  2. Place the folder in your PHP server (e.g., htdocs or www).
  3. Open example.php in your browser to test.

📖 Usage

Step 1: Include Captcha in Form

<?php include "nvcaptcha/captcha_view.php"; ?>

Step 2: Verify on Submit

if ($_SERVER['REQUEST_METHOD'] === "POST") {
    // Honeypot check
    if (!empty($_POST['nvc_trap'])) {
        die("Bot detected!");
    }
    // Captcha check
    if ($_POST['captcha_verified'] === "1") {
        echo "Form submitted successfully ✅";
    } else {
        echo "Captcha failed ❌";
    }
}

🧪 Example (example.php)

<?php session_start(); ?>
<!DOCTYPE html>
<html>
<head><title>Slider Captcha Demo</title></head>
<body>
<h2>Form with Slider Captcha</h2>
<form method="post" action="">
    <input type="text" name="name" placeholder="Your Name" required><br><br>
    <?php include "nvcaptcha/captcha_view.php"; ?><br>
    <button type="submit">Submit</button>
</form>

<?php
if($_SERVER['REQUEST_METHOD'] === "POST"){
    if(!empty($_POST['nvc_trap'])){ die("Bot detected!"); }
    if($_POST['captcha_verified'] === "1"){
        echo "<p style='color:green'>Form submitted successfully ✅</p>";
    } else {
        echo "<p style='color:red'>Captcha failed ❌</p>";
    }
}
?>
</body>
</html>

🖼️ Screenshot

PHP Slider Captcha Demo


About Me

I am Naveed, a passionate PHP developer. I specialize in creating modern, secure, and professional web applications using PHP, MySQL, and Bootstrap.

Check my GitHub for more projects: https://github.com/DigitalEforce


License

MIT License

About

Lightweight PHP slider captcha — no dependencies, secure (token, expiry, honeypot, attempt limit), shows match % after verification.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages