| | #1 |
| Warrior Member Join Date: 2016
Posts: 16
Thanks: 0
Thanked 3 Times in 2 Posts
|
How to use captcha in php?
|
| | |
| |
| | #2 |
| Warrior Member Join Date: 2016
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
|
This is very simple program captcha in php you should go to google and search captcha in php and you got hundred and more link and resolved your problem
|
| |
| | #3 |
| Warrior Member Join Date: 2016
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
<?php session_start(); include("./phptextClass.php"); /*create class object*/ $phptextObj = new phptextClass(); /*phptext function to genrate image with text*/ $phptextObj->phpcaptcha('#162453','#fff',120,40,10,25); ?> |
| |
| | #4 |
| Active Warrior Join Date: 2015 Location: Kherson, Ukraine
Posts: 42
Thanks: 0
Thanked 8 Times in 8 Posts
|
1. Create file "capcha.php": <?php $seccode = mt_rand(10000, 99999); session_start(); $_SESSION['seccode'] = $seccode; header("Content-Type: image/png"); $im = imagecreate(60, 18) or die('Error on create image!'); $corfundo = imagecolorallocate($im, 255, 244, 234); $corfonte = imagecolorallocate($im, 255, 128, 0); $corlinha = imagecolorallocate($im, 255, 200, 150); $corborda = imagecolorallocate($im, 255, 128, 0); for($x=10; $x <= 100; $x+=10){ imageline($im, $x, 0, $x, 50, $corlinha); } imageline($im, 0, 9, 100, 9, $corlinha); imageline($im, 0, 0, 0, 50, $corborda); imageline($im, 0, 0, 100, 0, $corborda); imageline($im, 0, 17, 100, 17, $corborda); imageline($im, 59, 0, 59, 17, $corborda); imagestring($im, 5, 8, 1, $seccode, $corfonte); imagepng($im); imagedestroy($im); ?> 2. Create file "check.php": <?php session_start(); if(isset($_POST['key']) AND isset($_SESSION['seccode']) AND $_POST['key']==$_SESSION['seccode']){ echo 1; } else { echo 0; } ?> 3. Create file "index.html": <html> <head><title>Capcha</title></head> <body> <form action="check.php" method="post"> <img src="capcha.php" alt="" /> <input type="text" name="key" /> <input type="submit" value="send" /> </form> </body> </html> |
| |
|
| Bookmarks |
| Tags |
| captcha, php |
| |