splizzer
Binary Builder
LEVEL 1
400 XP
In this article, we are going to create Captcha using PHP. This simple article will help you on how to create this simple captcha with this simple source code. Enable you to generate a random code and you can use this to protect your page from random spammers. You can use this also as a type of a simple test that the response is generated by a human being and it's a very common on other websites.
Creating random code, TextBox, and one button as shown in the image below.
Here's the short source code for the image above.
Here's the source code for generating a random code.
In the image below, if the user matches random code.
In the image below, if the user does not match the random code.
Hope that this article will help you a lot.
Share us your thoughts and comments below. Thank you so much for dropping by and reading this tutorial post. For more updates, don’t hesitate and feel free to visit this website more often and please share this with your friends or email me at [email protected]. Practice Coding. Thank you very much.
Download
Creating random code, TextBox, and one button as shown in the image below.

Here's the short source code for the image above.
- <form
class
=
"form-horizontal"
method
=
"POST"
>
- <img
src
=
"generatecaptcha.php?rand=<?php echo rand(); ?>
" id='image_captcha' >
- <a
href
=
'javascript: refreshing_Captcha();'
><i
class
=
"icon-refresh icon-large"
></
i
></
a
>
- <script
language
=
'JavaScript'
type
=
'text/javascript'
>
- function refreshing_Captcha()
- {
- var img = document.images['image_captcha'];
- img.src = img.src.substring(0,img.src.lastIndexOf("?"))+"?rand="+Math.random()*1000;
- }
- </
script
>
- <div
class
=
"control-group"
>
- <label
class
=
"control-label"
for
=
"inputPassword"
>
Enter the Code Above</
label
>
- <div
class
=
"controls"
>
- <input
id
=
"code"
name
=
"code"
type
=
"text"
placeholder=
"Enter the Code Above"
required></
td
>
- </
div
>
- </
div
>
- <div
class
=
"control-group"
>
- <div
class
=
"controls"
>
- <button
type
=
"submit"
name
=
"submit"
class
=
"btn btn-primary"
><i
class
=
"icon-ok icon-large"
></
i
>
Submit</
button
>
- </
div
>
- </
div
>
- </
form
>
Here's the source code for generating a random code.
- <
img src=
"generatecaptcha.php?rand=<?php echo rand(); ?>"
id=
'image_captcha'
>
- <
a href=
'javascript: refreshing_Captcha();'
><
i class
=
"icon-refresh icon-large"
></
i></
a>
- <
script language=
'JavaScript'
type=
'text/javascript'
>
- function
refreshing_Captcha(
)
- {
- var
img =
document.images
[
'image_captcha'
]
;
- img.src
=
img.src
.substring
(
0
,
img.src
.lastIndexOf
(
"?"
)
)
+
"?rand="
+
Math
.random
(
)
*
1000
;
- }
- </
script>
In the image below, if the user matches random code.

In the image below, if the user does not match the random code.

Hope that this article will help you a lot.
Share us your thoughts and comments below. Thank you so much for dropping by and reading this tutorial post. For more updates, don’t hesitate and feel free to visit this website more often and please share this with your friends or email me at [email protected]. Practice Coding. Thank you very much.
Download
You must upgrade your account or reply in the thread to view hidden text.