Captcha ?!

Started on the old forum in April 2010 · view the original in the archive · old links redirect here

#captcha-how-to-add

7 replies · 818 views · started 16 years ago · 1 min read

3 participants
Malka1 Developer · 169 posts #1

Can anyjone tell the simplies way to add captcha...

I've tried by watching that on other scripts, but i cant make my own... 🙁

Please explain the process, it will be very good if also can add some previews... 🙁

kiLLeR-eyEd_14 Senior · 382 posts #2

Save this as captcha.php

<?php
header('content-type: image/jpeg');
$height = 25;
$width = 55;
$image_p = imagecreate($width,$height);
$black = imagecolorallocate($image_p,0,0,0);
$white = imagecolorallocate($image_p,255,255,255);
$font_size = 14;
imagestring($image_p,$font_size,5,5,"".$_GET['text']."",$white);
imagejpeg($image_p,null,80);
?>

then in ur register form

$text = rand(11111,99999);
$rform .= "Image Verification\n<br/>\n<img src=\"captcha.php?text=$text\" alt=\"captcha\"/> = <input type=\"text\" format=\"*n\" name=\"ucans\" maxlength=\"5\" size=\"2\"/><br/>\n";
$rform .= "<input type=\"hidden\" name=\"rcans\" value=\"$text\"/>\n";

and in your register.php

$ucans = $_POST["ucans"];
$rcans = $_POST["rcans"];
if($ucans!=$rcans) echo "Wrong Image Verification!";

try diz..i just typed it now..don't know if it'll work and if u understand..just analyze..

kiLLeR-eyEd_14 Senior · 382 posts #3

Demo: Registration | UnderGroundWAP and captcha http://undergroundwap.co.cc/captcha.php?numOne=1&numTwo=2 param val of numOne is 1 and numTwo is 2..Their sum should be 3..this is different from what i've previously posted coz i use sum of 2 numbers and i just use random numbers in my post here..

Malka1 Developer · 169 posts #5

Try my captcha.php better

<?php
session_id("".$_GET['sid']."");
session_start();
    $string=rand(1000,10000);
    $_SESSION['ref'] = $string;
    Header("Content-type: image/gif");
    $im = ImageCreateFromGif("img.gif");
    $orange = ImageColorAllocate($im, 0, 0, 0);
    $px = (imagesx($im)-7.5*strlen($string))/2;
    ImageString($im,3,$px,1,$string,$orange);
    ImageGif($im);
    ImageDestroy($im);
?>

I dont know why, yours not workin for me..

Malka1 Developer · 169 posts #6

O.K i've found anauther way, btw thanx for previews, now i understand how "stuff" works.

O.K My preview:

Post it at Your input field

echo "*Security code:<br/>\n";
$r1=rand(0,100); $r2=rand(0,100); $r3=rand(0,100); $rand="$r1$r2$r3";
echo "<small><b>$rand</b></small><br/>\n";
echo "<input name=\"code\" maxlength=\"9\" title=\"infa\" emptyok=\"false\"/><br/>\n";

On postfield field place this:

<postfield name=\"code\" value=\"$(code)\"/>
<postfield name=\"kod\" value=\"$rand\"/>

At the register page place this:

if ($code=="") {
die
(print "Enter security code!<br/>
</small></p></card></wml>");
}
if ($code !== $kod) {
die
(print "Wrong security code!<br/>
</small></p></card></wml>");
}

Hope this helps someone 😉

P.S that works on wml, on html have probs

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close