PHP Captcha Scripts and Tutorial with Simple Question Answering
- PHP Captcha Scripts and Tutorials
- PHP Captcha Scripts and Tutorial with Arithmetic Question
- PHP Captcha Scripts and Tutorial with Text Copying
- PHP Captcha Scripts and Tutorial with Simple Question Answering
- PHP Captcha Scripts and Tutorial with reCAPTCHA
- PHP Captcha Scripts and Tutorial with Google reCAPTCHA
PHP Captcha Scripts and Tutorial with Arithmetic Question
PHP Captcha Scripts and Tutorial with Text Copying
PHP Captcha Scripts and Tutorial with Simple Question Answering
PHP Captcha Scripts and Tutorial with reCAPTCHA
PHP Captcha Scripts and Tutorial with Google reCAPTCHA
This page is a tutorial on "PHP Captcha Scripts and Tutorial with Simple Question Answering". Our overall method is to use a simple image of a challenge question and the sentence it refers to. Both PHP Captcha Scripts and Tutorial with Arithmetic Question
and PHP Captcha Scripts and Tutorial with Text Copying use the PHP GD Library and a TrueType font and PHP to make captchas. But this script just displays the image of the two sentences, as you can see in the example above.
Using Google reCAPTCHA is the safest free way to do captchas, and it's popular as well as effective. But it's more fun to make your own captcha system, like the ones we supply.
The rest of this page assumes you wish to use our simple question answering captcha script. There are lots of type of questions you can use, as you can see:
- Display a sample sentence and have your question be about it: "What is the third to the last word in this sentence?"
- Use common knowledge questions, like "How many states are there in the USA?" or "Who was the first US president?"
- Display a sample image and have your question be about it: "How many wheels are visible in the picture of the train locomotive?"
In all cases, you need to have the answer be in the PHP script on the form page, or the PHP script referenced in the action attribute of the form tag, since a bot can find it in a JavaScript variable but not in PHP code. We're all in a heap of trouble if they can peruse the PHP scripts on our servers! But checking out your HTML and JavaScript remotely is not that difficult.
The PHP Captcha Scripts and Tutorial with Simple Question Answering script isn't a script—it's a bunch of them. Anywhere you want a very simple captcha you may apply this method. Type text puzzles into your favorite graphics program. Our favorite graphics program is ImageForge. Save:
or some other question similar to it, as a .png image. Use it in your logins, registation scripts, polls, etc. We use it in register-by-email.html, PHP-guestbook-script.html, message-login.html, forum-login.html, chat-room-login.html, and blog-login.html.
Below is an excerpt from our private messaging login script, which uses the simple 2-sentence challenge that looks like this on the page:
and looks like this in HTML code:
<IMG SRC="login-question.png" WIDTH=295 HEIGHT=36 BORDER=0>
And here is the PHP code that looks for the right answer—"of"—and gives a message and reloads the page if the captcha challenge is not answered correctly (the PHP section is much longer than this, of course):
$L = $_POST['captcha'];if ($L<>"of"){
echo '<script language="javascript">alert("Please answer question."); window.location = "message-login.php"; </script>';
Here is an excerpt from our private messaging login script, which uses the simple 2-sentence challenge:
<h3>Login or Sign-up</h3>
<div id='pw' style='position:absolute;top:110px;left:600px;width:350px;border:4px solid blue;background-color:#8aa;'><table border='0' cellspacing=0 cellpadding=6><tr><th style='font-size:24;text-align:center'>Sign Up</th></tr>
<form id='formpw' name="formpw" method="post" action="message-login.php" onsubmit="return validatepassword()">
<tr><td><label for="User Name"><b>User Name: </b><input type="text" name="username" size="20" maxlength="20" value=""></label> </td></tr>
<tr><td><label for="Password"><b>Password: </b><input type="password" name="upassword" size="20" maxlength="20" value=""></label> </td></tr>
<tr><td><label for="Email"><b>Email: </b><input type="text" name="email" size="25" maxlength="65" value=""></label> </td></tr>
<tr><td><label for="Please answer question"><b>Please answer question: </b><input type="text" name="captcha" size="16" maxlength="16" value=""></label></td></tr>
<tr><td> <IMG SRC="login-question.png" WIDTH=295 HEIGHT=36 BORDER=0></td></tr>
<tr><td><BR>
<input type="submit" value="Submit" name="register">
<input type="reset" value="Reset"></form></td></tr></table>
</div>
<div id='login' style='position:absolute;top:110px;left:100px;width:350px;border:4px solid blue;background-color:#8aa;'><table border='0' cellspacing=0 cellpadding=6><tr><th style='font-size:24;text-align:center'>Login</th></tr>
<form id='formlogin' name="formlogin" method="post" action="message-login.php" onsubmit="return validatepasswordlogin()">
<tr><td><label for="User Name"><b>User Name: </b><input type="text" name="uname" size="20" maxlength="20" value=""></label> </td></tr>
<tr><td><label for="Password"><b>Password: </b><input type="password" name="upasswordlogin" size="20" maxlength="20" value=""></label> </td></tr>
<tr><td><BR>
<input type="submit" value="Submit" name="login">
<input type="reset" value="Reset"></form></td></tr></table>
</div>