Tuesday, April 19, 2016

How to make captcha with php

MAKE CAPTCHA

 

 


CAPTCHA is an acronym for "Completely Automated Public Turing test to tell Computers and Human Apart" which was created in 2000, to ensure answers on computers made by man, not by robots. CAPTCHA typically use letters and numbers and appear on a web page. CAPTCHA is also used to minimize Spam entries on a web page. CAPTCHA process usually involves the user to solve a CAPTCHA and computers that will assess the results of the simple test.
In the article, I will provide a tutorial to make CAPTCHA own guys by using PHP Script. CAPTCHA actually makes it easier, because guys just stay Generate some character and put it in the image and store it in a variable.
Remember .. CAPTCHA it is very important for a website, because with the help of CAPTCHA we can avoid spam.


Immediately wrote us consider the steps to make CAPTCHA with PHP Script

1. Creating web pages CAPTCHA

You can start by opening Notepad and type the script code below:


The script is already there is a form that consists of input username, password input and input CAPTCHA form.

Once this process is completed then we're done making the CAPTCHA on a web page.
As this zoom

 

2. Make a CAPTCHA Generate Script

Go back in Notepad and typing the following script:

<? Php

// Enable session
session_start ();

header ( 'Content-type: image / png ");

// Name the session with the name of Captcha
$ _SESSION [ 'Captcha'] = "";

// Set the image size
$ Gbr = ImageCreate (200, 50);

// Background color image
ImageColorAllocate ($ gbr, 167, 218, 239);

$ Gray = ImageColorAllocate ($ gbr, 128, 128, 128);

$ Black = ImageColorAllocate ($ gbr, 0, 0.0);

// Specify font
$ Font = "monaco.ttf";

// Create a random number and is shown in the picture
for ($ i = 0; $ i <= 5; $ i ++) {
// Number of characters
$ Number = rand (0, 9);

$ _SESSION [ "Captcha"]. = $ Number;

$ Angle = rand (-25, 25);

imagettftext ($ gbr, 20, $ angle, 8 + 15 * $ i, 25, $ black, $ font, $ number);

// Shadow effect
imagettftext ($ gbr, 20, $ angle, 9 + 15 * $ i, 26, $ gray, $ font, $ number);
}
// To create images
imagepng ($ gbr);
imagedestroy ($ gbr);
?>

The above code only in the form of PHP code to load the image, // specify the font
$ Font = "monaco.ttf";

Because ane select font that is Monaco, You could replace it.

3. Make the code or script results

Well after we create a web page and a CAPTCHA image, we now have to create code that helps the computer to provide a CAPTCHA test results, right or wrong.
Then you can just type the following script:

<Html>
<Head>
  <Title> Check Results CAPTCHA </ title>
</ Head>
<Body>
<P align = "center"> Results Login <br/>
<?
// Call another session to begin
session_start ();
if ($ _ SESSION [ "Captcha"]! = $ _ POST [ 'nilaiCaptcha "]) {
echo "Your Username". $ _ POST [ 'username']; echo "<br />";
echo "Your password". $ _ POST [ "password"]; echo "<br />";
echo "Captcha code You Wrong";
} Else {// if the sparks fly passes
echo "Your Username". $ _ POST [ 'username']; echo "<br/>";
echo "Your password". $ _ POST [ "password"]; echo "<br/>";
echo "Captcha code You Right";
}
?>
</ P>
</ Body>
</ Html>



If the results of CAPTCHA correctly, it will appear "correct CAPTCHA code" and if any of it will appear "CAPTCHA code you are wrong".


4. Trial

When finished, You need to test it, You go to a web page, then log in and enter a CAPTCHA.


Now that's how to make CAPTCHA using PHP Script, I hope this tutorial helps guys.

Thank you for visiting …

Share this

7 Responses to "How to make captcha with php"

  1. thank infonya gan

    ReplyDelete
  2. Today is the choice of fine Rolex watches meeting all suffered more. Arrive feel cool Swiss Rolex watches acquisition, you will need to ; Display Replica Rolex Watches use real advantage, eloquent, and recognized Louis Vuitton handbags lovers one day. The following are selected conference Replica Hermes handbags ...... Take your pick!

    ReplyDelete
  3. Nice article bro, now i know how to make captcha use php

    ReplyDelete

HOW TO ARTICLES ABOVE?

Please provide your comments relevant dikolom below, to establish silaturrahmi. or you can also use facebook to comment on the above column.

commented politely and suggested to give constructive criticism.

DO NOT SPAM commented, because our system automatically detects spam and reflects poorly on your site

Thanks
By Admin OF http://www.thelatestgalaxy.blogspot.com