PHP Classes

PHP Login Pad Class: Display and validate digits for the user to enter

Recommend this page to a friend!
  Info   View files Example   Demos   Screenshots Screenshots   View files View files (3)   DownloadInstall with Composer Download .zip   Reputation   Support forum (2)   Blog (1)    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 159 All time: 8,982 This week: 488Up
Version License PHP version Categories
loginpadclass 0.4GNU General Publi...5HTML, Validation, Security
Description 

Author

This class can display and validate digits for the user to enter.

It can take code made of digits from 0 to 9 and renders a pad arranged randomly made of 16 buttons that the user needs to click on the right buttons to match the validate code digits.

The class can also check if the user has clicked on the right buttons with digits that match the code that was provided initially.

Depending on the configuration of the class, the code can be typed on the keyboard or necessarily with the mouse. It can optionally be used to avoid robots.

Innovation Award
PHP Programming Innovation award nominee
January 2021
Number 3


Prize: SourceGuarding PHP encoder tool
Some times it is necessary that applications verify if a user accessing the site is a real human, rather than a robot script that its trying to abuse from the system resources.

This class provides a solution that consists of a key pad that displays on a Web page. Then the users need to click or touch on keys that appear on the screen to demonstrate that they are real humans to enter the right codes by the right order.

This way this solution can work well on computers on which people can use the mouse to point and click in the buttons in the right order with the codes that appear on the page.

It also works well on devices with a touch screen like mobile phones, tablets or computers with a touch screen, as the users just need to touch the buttons to achieve the same effect as clicking on the buttons using the mouse.

Manuel Lemos
Picture of Pierre FAUQUE
  Performance   Level  
Name: Pierre FAUQUE <contact>
Classes: 18 packages by
Country: France France
Age: 77
All time rank: 15312 in France France
Week rank: 280 Down11 in France France Up
Innovation award
Innovation award
Nominee: 12x

Winner: 1x

Example

<?php
require("class.loginPad.php");

$kp = new loginPad("17081936",1); // Instanciation with the access code
$kp->rep = 0; // 1:report error (default), 0: don't report anything

if(isset($_POST["submit"])) {
    if(
$kp->isGoodInput()) {
       
// header("location: access.php"); // Access to the right page
        // header("location: one-file.zip"); // Download a file
        // ... Or other action...
       
echo "<!DOCTYPE html>\n";
        echo
"<html>\n\n";
        echo
"<head>\n";
        echo
"<title>Authorized page</title>\n";
        echo
"<style type=\"text/css\">\n";
        echo
"body { font-family:arial; font-size:1em }\n";
        echo
"img { margin-left:25px; border:1px solid grey }\n";
        echo
"</style>\n";
        echo
"</head>\n\n";
        echo
"<body>\n";
        echo
"<h1>Correct code</h1>\n";
        echo
"<p>The code is correct. You can do what you want :\n";
        echo
"<ul>\n";
        echo
"<li> display a new page,</li>\n";
        echo
"<li> delete a record,</li>\n";
        echo
"<li> start a download,</li>\n";
        echo
"<li> etc.</li>\n";
        echo
"</ul>\n";
        echo
"<p>Margaret Hamilton and it's Appolo code :<br/>&nbsp;<br/>";
        echo
"<img src=\"Appolo-code-of-Margaret-Hamilton.jpg\"></p>\n";
        echo
"</body>\n\n";
        echo
"</html>\n";
        die(); }
    else {
       
$kp->countErr();
    }
}
?><!DOCTYPE html>
<html>

<head>
<title>Test page</title>
<style type="text/css">
p { font-family:arial; font-size:1em }
a { text-decoration:none }
a:hover { color:red }
</style>
</head>

<body>
<p>
  Click on the keys to enter the access code and validate<br/>
  with the Send button (or cancel with the Clear button)<br/>
  NB: The code is 17081936 (birthday of <a href="https://en.wikipedia.org/wiki/Margaret_Hamilton_(software_engineer)" target="_blank">Margaret Hamilton</a>)
</p>

<?php $kp->writeKeypad(); ?>

<p>&nbsp</p>
<p><a href="index1.php">Try with no code input zone</a></p>

</body>

</html>


  Démo on the author's websiteExternal page  
Screenshots  
  • screenshots.jpg
  Files folder image Files  
File Role Description
Plain text file class.loginPad.php Class The class itself (user guide included)
Accessible without login Plain text file index.php Example Example of use
Accessible without login Plain text file README.txt Data Summary (URL and PGP Key)

 Version Control Unique User Downloads Download Rankings  
 0%
Total:159
This week:0
All time:8,982
This week:488Up
User Comments (1)
Great little piece of code.
3 years ago (Valentin)
70%StarStarStarStar