| | |||||
| ||||||||
| CODE This forum is for posting code snippets and example scripts that aren't quite tutorials, but could be useful for others. You may post code snippets and/or completed scripts that you've written and want to share here. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| Account Suspended Join Date: Dec 2008 Location: Boston, Ma
Posts: 650
![]() ![]() ![]() ![]() ![]() ![]() | |
| | |
| | #3 (permalink) | ||||
| NamePros Regular Join Date: Jul 2007 Location: UK
Posts: 394
![]() ![]() ![]() ![]() ![]() ![]() ![]() | Great stuff. Thanks for sharing. You might want to lowercase the visitor's answer before md5ing it to avoid rejecting someone typing "Yes", when you expected "yes". I personally hate the ones that ask you to complete a word (I find this hard for some reason - I guess just the way my brain is wired). Also some questions are aimed at a particular culture or language variant. This is one I get asked quite often at one forum (it obviously has a limited set of questions): ????: NamePros.com http://www.namepros.com/showthread.php?t=642705
I'd probably use arrays for storing Q's and A's.
__________________ | ||||
| | |
| | #9 (permalink) |
| Tech Support Join Date: Mar 2005
Posts: 4,944
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | I changed 'whatever.php' to the below. I dunno, that switch just made me cringe (not that all these arrays are that much better, but meh )PHP Code: |
| | |
| | #11 (permalink) | ||||
| Tech Support Join Date: Mar 2005
Posts: 4,944
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
????: NamePros.com http://www.namepros.com/showthread.php?t=642705 My main reason for doing it the way I did, is readability. I think using the array's instead of giant switch statement is much more readable. JMO | ||||
| | |
| | #13 (permalink) |
| Senior Member Join Date: Jun 2008 Location: nodws.com
Posts: 1,666
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | much better to say Code: $n1=rand(0,9);
$n2=rand(0,9);
$result=$n1+$n2+1; //we add 1, or any
$question="what is $n1 + $n2?";
//we echo the form and hide the result
echo"<form method=post>$question <input name=question><input type=hidden name=result value=$result></form>";
//we validate and subtract 1
if(($_POST[result]-1)===$_POST[question])
{
echo"you are human!"; //hurray, no switch()
}
__________________ SnackNames.com | SnackDesign.com | buckstabu.com | adoolt.com | yoAmoNY.com Developer For Hire! PHP/MySQL/Wordpress/Etc Graphic design, Corporate ID, Dev Ideas
Last edited by Nodws; 04-09-2010 at 12:20 AM.
|
| | |
![]() |
| Tags |
| captcha alternative, php code |
LinkBacks (?)
LinkBack to this Thread: http://www.namepros.com/code/642705-simple-human-verification-code.html | ||||
| Posted By | For | Type | Date | |
| Simple Human Verification with CodeIgniter Form Validation | Web Success - atomni | This thread | Refback | 10-28-2011 01:08 AM | |
| Simple Human Verification with CodeIgniter Form Validation | Web Success | This thread | Pingback | 10-21-2010 12:41 PM | |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |