Hello,
This is just a small script to have the user enter a captcha without images. This captcha is generated by text.
I did not test this in a HTML supported browser so I only had access to making sure that the script for php had worked which it did. HTML Login alignment may or will be messed up or inaccurate but the function does work.Code://Quick script
<html>
<body>
<?php
$captcha = 'captcha';
$capshuffle = str_shuffle($captcha);
$halfcaptcha = substr($captcha, 1, strlen($capshuffle)/2);
echo $capshuffle;
if (isset($captcha)) //This can be changed to if (script) == 1 for positive redirect include form
{
//Code to execute here example...
/*
*@You can set this to include(@YourLoginScript) so that it will redirect to your home.php or html
*/
}
else if ($_GET['captcha'] = '') {
echo "The captcha you entered was incorrect.";
}
?>
<form action = "home.php" method = "get" />
Username: <input type = "text" name = "username" />
Password: <input type = "password" name = "password" />
Captcha: <input type = "text" name = "captcha" value = "..." onclick = "this.value=''">
<input type = "submit" name = "submit" value = "Login" />
</form>
</body>
</html>
Let me break each line down:
On this line we are creating a string which we gave a value. I used the word 'captcha' but any other word will work.Code:$captcha = 'captcha'; //
next:
Next we use the 'str_shuffle' command to randomize our string word named captcha.Code:$capshuffle = str_shuffle($captcha); //
next:
We assign a new variable and use the 'substr' to return a small portion of our string that is specificed from it's arugments. the 'substr' function allows 3 arguments to be passed. 'strlen' is used to count the amount of characters used in our string we made then divide that string by 2.Code:$halfcaptcha = substr($captcha, 1, strlen($capshuffle)/2);
next:
Now we want to print out our yet shuffled word but also shortened string. Your output should be 5 characters long randomized to it's best.Code:echo $capshuffle;
next:
After most of our needed functions for the captcha to work are done. We then are now checking if the user entered the captcha.Code:if (isset($captcha))
This line of code checks if our string $captcha is set and is not 'nulled' or empty.
After the check it will execute whatever code you want it to below.
This line of code will return the captcha and check if it's blank or a value is set . If not then it will return your desired message, in this example I made it execute "no string has been entered".Code:else if ($_GET['captcha'] = '')
next:
This line will redirect the page from it's current to the desired 'home.php' while using the method GET.Code:<form action = "home.php" method = "get" />
next:
This line of code will be used based on the information that is represented in your PHP script. Since I've set a value to '...' it will appear in the text box. I included onclick so that once the user has pressed or clicked inside the box it will automatically disappear.Code:Captcha: <input type = "text" name = "captcha" value = "..." onclick = "this.value=''">
You may want to write the captcha inside a different .php then have it just "require_once(".php") for more understanding.
~ I hope you have use for it.

