<MvCOMMENT>
############################################################################## #
Simple graphical code method to help "verify" a form entry

Adding these snippets to a form will put one of those verification boxes that
require the user to enter what numbers and letters they see from a group of
images.  If you have forms with public entry that are experience "viagra spam"
and such, this little routine can help.

Don't use this for anything that needs heavy security.  The CRYPT operator in
mivascript is not very advanced and there are other mivascript encryption tools
that are much more secure.

Step 1: copy the "verify" directory to your script location.  The verify directory
contains the gif files that are used for the verification code.

Scot Ranney
http://www.scotsscripts.com
############################################################################## #
</MvCOMMENT>


<MvCOMMENT>
############################################################################## #
Step 1:

Copy the code below into your scrpt, just below the opening <form...> tag.

Change the three letter key on lines 51 and 67 to anything you want- they must be the same.
############################################################################## #
</MvCOMMENT>

	<MvASSIGN NAME = "l.ran" index="1" VALUE = "{ random(9) + 1 }">
	<MvASSIGN NAME = "l.ran" index="2" VALUE = "{ random(9) + 1 }">
	<MvASSIGN NAME = "l.ran" index="3" VALUE = "{ random(9) + 1 }">
	<MvASSIGN NAME = "l.ran" index="4" VALUE = "{ random(9) + 1 }">
	<MvASSIGN NAME = "l.ran" index="5" VALUE = "{ random(9) + 1 }">
	<MvASSIGN NAME = "l.ran" index="6" VALUE = "{ random(9) + 1 }">

	<MvWHILE EXPR = "{l.index NE 6}">
		<MvASSIGN NAME = "l.index" VALUE = "{ l.index + 1 }">
		<MvIF EXPR = "{l.ran[l.index] LE 6}">
			<MvASSIGN NAME = "l.code" VALUE = "{ l.code $ l.ran[l.index] }">
			<MvASSIGN NAME = "l.img" VALUE = "{ l.img $ '<img src="verify/' $ l.ran[l.index] $ '.gif"> ' }">
		<MvELSE>
			<MvASSIGN NAME = "l.img" VALUE = "{ l.img $ '<img src="verify/' $ asciichar(l.ran[l.index] + 60) $ '.gif"> ' }">
			<MvASSIGN NAME = "l.code" VALUE = "{ l.code $ asciichar(l.ran[l.index] + 60) }">
	 	</MvIF>
	</MvWHILE>

	<MvASSIGN NAME = "l.key" VALUE = "{ l.code CRYPT 'abc' }">
	<MvHIDE FIELDS = "l.key">

	Enter the following code into the box at the right: <MvEVAL EXPR = "{l.img}">  <input type="text" name="code" size="6">

<MvCOMMENT>
############################################################################## #
step 2: add the code below to the page/function that your form is posting to.

This takes the code that the person put in and creates a new key out of it and
compares it to the key that was submitted as a hidden variable in the form (from
the code above).
############################################################################## #
</MvCOMMENT>

	<MvASSIGN NAME = "g.code" VALUE = "{ trim(toupper(g.code)) }">
	<MvASSIGN NAME = "l.new_key" VALUE = "{ g.code CRYPT 'abc' }">

	<MvIF EXPR = "{l.new_key NE g.key}">
		<P>
		<B>Error:</b> you did not enter the code on the previous page correctly.
		<MvFUNCRETURN VALUE = "{ 0 }">
	</MvIF>

