Doar copiezi si apoi adaugi in public_html
index.php
<?php //inceput coloana
session_start(); //start
if ( isset( $_POST['submit'] ) )
{
$code = strip_tags( $_POST['code'] ); //tagul
$real_code = $_SESSION['captcha_code']; //codul real
if ( $code !== $real_code ) //codul real
{
echo "Wrong code! Code was {$real_code}"; //Cod gresit
}
else
{
echo "Correct code!"; //Cod incorect!
}
}
else
{
?>
<form method="post">
<img src="captcha.php" /><br />
Enter code: <input type="text" name="code" /> <input type="submit" name="submit" value="Go" /> //scrierea codului pe imagine
</form>
<?php
}
?>
captcha.php
<?php
/* This tutorial will teach you how to create your own Captcha image. */
session_start(); //Amestecarea
$chars = "1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM"; //Definitiile
$length = ( isset( $_GET['l'] ) && is_numeric( $_GET['l'] ) ) ? (int)$_GET['l'] : 8; //La 8 este de cate cifre este format definitia ex " SFe3rGGt " poti pune tu cate vrei ex: 10 -
$captcha = "";
for ( $i = 1; $i <= $length; $i++ )
{
$captcha .= $chars[ mt_rand( 0, strlen( $chars ) ) ];
}
$_SESSION['captcha_code'] = $captcha;
$width = ( $length * 10 ) - 3; //Lungimea imagini
$img = imagecreate( $width, 17 ); //creiarea imagini
$bg = imagecolorallocate( $img, 0, 0, 0 ); //black
$txt = imagecolorallocate( $img, 255, 255, 255 ); //white
imagestring( $img, 5, 3, 1, $captcha, $txt ); //textul
header( "Content-Type: image/PNG" ); //Extensia
imagepng( $img ); //extensia
imagedestroy( $img ); //Amestecarea
?> //terminare coloana