i will do it in the morning and post back here.
Heres a simple php capcha script
Collapse
X
-
just create your own encoding and decoding function, its simple, i.e. replace 0 with a, b with 2 and convert it back on the captcha check page
Leave a comment:
-
mmm i think i've got a way, but i will also use this little coding as well, because bots use source instead of html...
check pageCode:<form action="4.php" method="post"> <label>Test</label><br /> <input type="text" name="test" /> <div style="visibility: hidden"> <label>I'm a human</label> <input type="checkbox" name="human" value="robit" /> </div> <input type="submit" value="Submit" /> </form>
Suppose i can ad a few fields and try and trick the bots this way as well?Code:<?php $test=$_POST['test']; if (empty($_POST['human'])) { echo "You are a human"; } else { echo "You are a bot"; } ?>
It's a simple code, but any defence should be better than none?
Leave a comment:
-
still not safe since grabbers can read the text value from image tag,
you should create some own encoding function which will encode the text value for image tag, and decode it back to normal in the captcha check page.
Leave a comment:
-
Originally posted by GumSlone View Postbots or just simple grabbers will be able to read it
Lol you are right....
That's why i did this one.
Insert or edit this to the form of the page.
that should go on the page where you $_POSTCode:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <div align="center"> <div align="center" style="color:#FF0000; border:#FF0000 thin solid; width:15%"> <form action="2.php" method="post"> <?php $random_number = rand('1','9999'); echo "<img src=\"img.php?text=$random_number\" alt=\"$random_number\" /><br />"; ?> <b>Please enter the verification code as above</b><br /> <input name="result" type="text" size="6" /><br /> <input name="random_number" type="hidden" value="<?=$random_number; ?>" /> <input type="submit" value="Submit" /> </form> </div> </div> </body> </html>
And this is my img.php fileCode:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <?php $result = $_POST["result"]; $random_number = $_POST["random_number"]; if ($result == $random_number) { // captcha is OK echo "<script>alert('Correct answer');</script>"; } else { // wrong captcha echo "<script>alert('Wrong answer entered, please retry');</script>"; } ?> </body> </html>
You think this will work better?Code:<?php header('Content-Type: image/png'); $im = imagecreatetruecolor(70, 30); $white = imagecolorallocate($im, 255, 255, 255); $grey = imagecolorallocate($im, 128, 128, 128); $black = imagecolorallocate($im, 0, 0, 0); imagefilledrectangle($im, 0, 0, 399, 29, $white); $text = $_GET['text']; $font = 'georgia.ttf'; imagettftext($im, 20, 0, 10, 20, $black, $font, $text); imagepng($im); imagedestroy($im); ?>
Leave a comment:
-
Heres a simple php capcha script
In the form that you want to submit ad the following code
Ok, in the submit page ad the following codeCode:<?php $min_number = 1; $max_number = 10; $random_number1 = mt_rand($min_number, $max_number); $random_number2 = mt_rand($min_number, $max_number); echo "<span style=\"background-color:#000000; color:#FFFFFF; border:#000099 thin solid\"><b><big>$random_number1 + $random_number2</big></b></span><br />"; ?> <input name="result" type="text" size="3" /><br /> <input name="n1" type="hidden" value="<?=$random_number1; ?>" /> <input name="n2" type="hidden" value="<?=$random_number2; ?>" />
This is just an example, but it can be more modified, but this is a simple way of having a capcha system on your website.Code:<?php $result = $_POST["result"]; $n1 = $_POST["n1"]; $n2 = $_POST["n2"]; $total = $n1 + $n2; if ($result == $total) { // Paste content here, which will show if the code is entered correct. I left the javascript in just to make it easier for you to understand for first use. echo "<script>alert('Correct answer');</script>"; } else { // If the code is wrong it will outpt this... echo "<script>alert('Wrong answer entered, please retry');</script>"; } ?>
I will be posting another code too soon which uses images instead of text.Tags: None
Leave a comment: