[ic] inserting into userdb table through a form

Bill Carr interchange-users@icdevgroup.org
Fri Jul 12 10:30:11 2002


--=-QmOB8WaCovM4sgq66Xvi
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

On Fri, 2002-07-12 at 07:36, Martin Abell wrote:
> On 7/12/02, Bill Carr wrote in response to Brent Kelley :
> 
> > I think you need to add
> > <INPUT TYPE="hidden" NAME="mv_todo" VALUE="set">
> > 
> > You could also use the userdb new_account function. Call it into action
> > via mv_click=NewAccount. That way you will get some checks like password
> > eq verify. Use a mv_form_profile to check your required fields. I think
> > you might have to do a userdb save after creating the new account but I
> > am not sure.
> > 
> > I just did this so I will post the page if you want it.
> > 
> > Bill Carr
> > Worldwide Impact
> > bill@worldwideimpact.com
> > 413-253-6700
> 
> I would like to see the page.  Then I won't have to work through it for a
> customer who just complained yesterday that it is possible to have user id
> linked to a userdb record with no info in it.
Here it is. I have not tested it much. I think it's right.

-- 
Bill Carr
Worldwide Impact
bill@worldwideimpact.com
413-253-6700

--=-QmOB8WaCovM4sgq66Xvi
Content-Disposition: attachment; filename=profile.txt
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; name=profile.txt; charset=ISO-8859-1

__NAME__ New_account

[if type=3Dexplicit compare=3D|[perl global=3D1]
                                                  use Vend::UserDB;
                                                  my $obj =3D new Vend::Use=
rDB;
                                                  return $obj->{DB}->record=
_exists($CGI->{mv_username});
                                        [/perl]|
]
        mv_nextpage=3Dord/existing_user
[if !session logged_in]
        [if type=3Dexplicit compare=3D'[userdb new_account]']
                [seti t][userdb save][/seti]
                mv_nextpage=3D[either][cgi mv_successpage][or]ord/shipto[/e=
ither]
        [else]
                mv_nextpage=3D[either][cgi mv_failpage][or]ord/new_account[=
/either]
        [/else]
        [/if]
[else]
        [if type=3Dexplicit compare=3D"[userdb
                                                        function=3Dsave
                                                        username=3D'[cgi mv=
_username]'
                                                ]"
        ]
                mv_nextpage=3D[either][cgi mv_successpage][or]ord/placeorde=
r[/either]
        [else]
                mv_nextpage=3D[either][cgi mv_failpage][or][cgi mv_nextpage=
][/either]
        [/else]
        [/if]
[/else]
[/if]

__END__

--=-QmOB8WaCovM4sgq66Xvi
Content-Disposition: attachment; filename=new_account.html
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; name=new_account.html; charset=ISO-8859-1

[comment]
[if session logged_in][bounce href=3D"[area account]"][/if]
[/comment]

[set newAccountCheck]
[if type=3Dexplicit compare=3D|[perl global=3D1]
						  use Vend::UserDB;
						  my $obj =3D new Vend::UserDB;
						  return $obj->{DB}->record_exists($CGI->{mv_username});
					[/perl]|
]
	&set=3Dmv_nextpage ord/existing_user
[else]
	[calc]
		return unless $CGI->{jurisdictions};
		$CGI->{jurisdictions} =3D~ s/\0/,/g;
		return;
	[/calc]
	fname=3Drequired Please enter your first name
	lname=3Drequired Please enter your last name
	[if cgi mv_username]
		mv_username=3Demail
	[else]
		mv_username=3Drequired You must supply an e-mail address
	[/else]
	[/if]
	mv_password=3Drequired You must supply a password
	mv_verify=3Drequired You must verify your password
	address1=3Drequired Please enter your address
	city=3Drequired Please enter your city
	state=3Drequired Please enter your state
	zip=3Drequired Please enter your zip
	phone_day=3Drequired Please enter your phone number
[/else]
[/if]
[/set]

[tmp page_title]__COMPANY__ -- New Account[/tmp]
__LAYOUT_START__
	<p class=3Dh1>Create New Customer Account</p>
	<br>
	[if cgi new_account_submit]
	[if type=3Dexplicit compare=3D"[error all=3D1 show_var=3D1 keep=3D1]"]
		<P class=3Derror>[error all=3D1 keep=3D0 show_error=3D1 show_label=3D0 jo=
iner=3D"<br>"]</p>
		<br>
	[elsif session failure]
		<P class=3Derror>
		  [data session failure]
		   [data base=3Dsession field=3Dfailure value=3D""]
		</P>
		<br>
	[/elsif]
	[/if]
	[/if]
	[seti width][calc]int(__CONTENTWIDTH__ * .9);[/calc][/seti]
	<p>Complete all <span class=3DinputRequired>required fields</span>.</p>
	<br>
	<FORM ACTION=3D"[process-target]" METHOD=3DPOST name=3Dn>
		<input type=3Dhidden name=3Dmv_session_id value=3D"[data session id]">
		<INPUT TYPE=3Dhidden NAME=3Dmv_todo  VALUE=3Dreturn>
		<INPUT TYPE=3Dhidden NAME=3Dfunction  VALUE=3Dnew_account>
		<INPUT TYPE=3Dhidden NAME=3Dmv_nextpage VALUE=3D@@MV_PAGE@@>
		<INPUT TYPE=3Dhidden NAME=3Dmv_failpage VALUE=3D@@MV_PAGE@@>
		<INPUT TYPE=3Dhidden NAME=3Dmv_successpage VALUE=3D"[either][cgi mv_retur=
npage][or]ord/payment_info[/either]">
		<INPUT TYPE=3Dhidden NAME=3Dmv_form_profile VALUE=3DnewAccountCheck>
		<INPUT TYPE=3Dhidden NAME=3Dmv_check VALUE=3DNew_account>
		<INPUT TYPE=3Dhidden NAME=3Dmv_cookie_password VALUE=3D1>
		<INPUT TYPE=3Dhidden NAME=3Dnew_account_submit VALUE=3D1>
		[margin-table
			width=3D'[scratch width]'
			headlinecolor=3D__COLORS_TB1__
			headline=3D'<span class=3Dh3>Login Information</span>'
			bordercolor=3D__COLORS_BORDER__
		]
		<table>
			<tr>
				<th class=3DinputName align=3Dright>[error name=3Dfname std_label=3D'Fi=
rst Name' required=3D'[if !cgi fname]1[/if]' show_error=3D0]</th>
				<td width=3D8><img src=3D/images/wi/shim.gif width=3D8 height=3D1></td>
				<td><INPUT NAME=3Dfname VALUE=3D"[either][cgi fname][or][value fname][/=
either]"></td>
			</tr>
			<tr>
				<th class=3DinputName align=3Dright>[error name=3Dlname std_label=3D'La=
st Name' required=3D'[if !cgi lname]1[/if]' show_error=3D0]</th>
				<td width=3D8><img src=3D/images/wi/shim.gif width=3D8 height=3D1></td>
				<td><INPUT NAME=3Dlname VALUE=3D"[either][cgi lname][or][value lname][/=
either]"></td>
			</tr>
			<tr>
				<th class=3DinputName align=3Dright>[error name=3Dmv_username std_label=
=3D'E-mail address' required=3D'[if !cgi mv_username]1[/if]' show_error=3D0=
]</th>
				<td width=3D8><img src=3D/images/wi/shim.gif width=3D8 height=3D1></td>
				<td><INPUT NAME=3Dmv_username VALUE=3D"[either][cgi mv_username][or][va=
lue mv_username][or][read-cookie MV_USERNAME][/either]"></td>
			</tr>
			<tr>
				<th class=3DinputName align=3Dright>[error name=3Dmv_password std_label=
=3D'Password' required=3D'[if !cgi mv_password]1[/if]' show_error=3D0]</th>
				<td width=3D8><img src=3D/images/wi/shim.gif width=3D8 height=3D1></td>
				<td><INPUT TYPE=3Dpassword NAME=3Dmv_password VALUE=3D"[either][cgi mv_=
password][or][value mv_password][or][read-cookie MV_PASSWORD][/either]"></t=
d>
			</tr>
			<tr>
				<th class=3DinputName align=3Dright>[error name=3Dmv_verify std_label=
=3D'Verify' required=3D'[if !cgi mv_verify]1[/if]' show_error=3D0]</th>
				<td width=3D8><img src=3D/images/wi/shim.gif width=3D8 height=3D1></td>
				<td><INPUT TYPE=3Dpassword NAME=3Dmv_verify VALUE=3D"[either][cgi mv_ve=
rify][or][value mv_verify][/either]"></td>
			</tr>
		</table>
		[/margin-table]
		<br>
		<br>
		[margin-table
			width=3D'[scratch width]'
			headlinecolor=3D__COLORS_TB1__
			headline=3D'<span class=3Dh3>Business Address</span>'
			bordercolor=3D__COLORS_BORDER__
		]
		<table>
			<tr>
				<th class=3DinputName align=3Dright>Firm Name</th>
				<td width=3D8><img src=3D/images/wi/shim.gif width=3D8 height=3D1></td>
				<td><INPUT NAME=3Dcompany VALUE=3D"[either][cgi company][or][value comp=
any][/either]"></td>
			</tr>
			<tr>
				<th class=3DinputName align=3Dright>[error name=3Daddress1 std_label=3D=
'Address' required=3D'[if !cgi address1]1[/if]' show_error=3D0]</th>
				<td width=3D8><img src=3D/images/wi/shim.gif width=3D8 height=3D1></td>
				<td><INPUT NAME=3Daddress1 VALUE=3D"[either][cgi address1][or][value ad=
dress1][/either]"></td>
			</tr>
			<tr>
				<th class=3DinputName align=3Dright></th>
				<td width=3D8><img src=3D/images/wi/shim.gif width=3D8 height=3D1></td>
				<td><INPUT NAME=3Daddress2 VALUE=3D"[either][cgi address2][or][value ad=
dress2][/either]"></td>
			</tr>
			<tr>
				<th class=3DinputName align=3Dright>[error name=3Dcity std_label=3D'Cit=
y' required=3D'[if !cgi city]1[/if]' show_error=3D0]</th>
				<td width=3D8><img src=3D/images/wi/shim.gif width=3D8 height=3D1></td>
				<td><INPUT NAME=3Dcity VALUE=3D"[either][cgi city][or][value city][/eit=
her]"></td>
			</tr>
			<tr>
				<th class=3DinputName align=3Dright>[error name=3Dstate std_label=3D'St=
ate' required=3D'[if !cgi state]1[/if]' show_error=3D0]</th>
				<td width=3D8><img src=3D/images/wi/shim.gif width=3D8 height=3D1></td>
				<td>
					[selector
						nullname=3D'--- State ---'
						table=3Dstates
						compare=3D'[either][cgi state][or][value state][/either]'
					]
				</td>
			</tr>
			<tr>
				<th class=3DinputName align=3Dright>[error name=3Dzip std_label=3D'Zip'=
 required=3D'[if !cgi zip]1[/if]' show_error=3D0]</th>
				<td width=3D8><img src=3D/images/wi/shim.gif width=3D8 height=3D1></td>
				<td><INPUT NAME=3Dzip VALUE=3D"[either][cgi zip][or][value zip][/either=
]"></td>
			</tr>
			<tr>
				<th class=3DinputName align=3Dright>[error name=3Dphone_day std_label=
=3DPhone required=3D'[if !cgi phone_day]1[/if]' show_error=3D0]</th>
				<td width=3D8><img src=3D/images/wi/shim.gif width=3D8 height=3D1></td>
				<td><INPUT NAME=3Dphone_day VALUE=3D"[either][cgi phone_day][or][value =
phone_day][/either]"></td>
			</tr>
			<tr>
				<th class=3DinputName align=3Dright>Fax</th>
				<td width=3D8><img src=3D/images/wi/shim.gif width=3D8 height=3D1></td>
				<td><INPUT NAME=3Dfax VALUE=3D"[either][cgi fax][or][value fax][/either=
]"></td>
			</tr>
		</table>
		[/margin-table]
		<br>
		<br>
		[margin-table
			width=3D'[scratch width]'
			headlinecolor=3D__COLORS_TB1__
			headline=3D'<span class=3Dh3>In what jurisdictions are you licenced?</sp=
an>'
			bordercolor=3D__COLORS_BORDER__
		]
			[query
				list=3D1
				sql=3D|SELECT state, name FROM states ORDER BY name|
			]
				[on-match]
					[table-organize
						columnize=3D1
						cols=3D4
						embed=3Duc
						table=3Dwidth=3D100%
					]
				[/on-match]
				[list]
					<TD>
						<input type=3Dcheckbox name=3Djurisdictions value=3D"[sql-param state=
]"[if term=3D"'[cgi jurisdictions]'" op=3D=3D~ compare=3D"'[sql-param state=
]'"]CHECKED[/if]>&nbsp;[sql-param name]
						<br>
					</TD>
				[/list]				=09
				[on-match]
					[/table-organize]
				[/on-match]
			[/query]
		[/margin-table]
		<br>
		<br>
		<input type=3Dsubmit name=3Dsubmit value=3D"Create Account">
		<br>
	</form>
	<pre>
[perl global=3D1]
	use Data::Dumper;
	Dumper($Session);
[/perl]
</pre>

__LAYOUT_END__
--=-QmOB8WaCovM4sgq66Xvi--