• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Remembering form fields

LEGEND ,
Jul 13, 2006 Jul 13, 2006

Copy link to clipboard

Copied

While this is quite easy in Classic ASP, I fear this will be a lot of coding
in CF. lol

I have a new member registration form that checks the username first prior
to continuing onto the next reg page.

If the member chooses a username that already exists they are directed back
to the page with a message that states that the username has already been
chosen which is a simple <cfif> that takes the value from the URL and states
text:

<cfif username NEQ "">Sorry, that username has already been taken, please
try again!</cfif>

That works fine...however.. All the form fields return to blank.

In ASP I just binded the values of the fields to URL and passed all the used
variables to the URL string (long and annoying, but worked fine).

If there were no variables, i.e. the page was first launched, all the text
areas came up blank. In CF it tells me that all the variables do not exist.

Would I have to use <CFparam> to create all blank variables to start and
then bind the text fields to them, which will cause the change if the
username is taken or is there a simple clean way to do this without the
hassle of creating variables first.

All I am looking for it to do, if the username is taken, is to show the
message and keep all the entered information in the text fields, except the
originally chosen username, so they don't have to reenter EVERYTHING over
again each time.

Thanks.

--
Wally Kolcz
Developer / Support


TOPICS
Advanced techniques

Views

260

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 13, 2006 Jul 13, 2006

Copy link to clipboard

Copied

I don't know if this will help, but here is the checkusername code:

<cfquery name="un_search" datasource="#Request.MainDSN#">
SELECT username FROM members WHERE username='#FORM.username#'
</cfquery>
<cfif un_search.RecordCount GTE 1>
<cflocation url="index.cfm?requsername=#FORM.username#&username=taken"
addtoken="no">
</cfif>


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 13, 2006 Jul 13, 2006

Copy link to clipboard

Copied

Add the rest of the form variables to the url attribute of your cflocation tag.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 13, 2006 Jul 13, 2006

Copy link to clipboard

Copied

Yeah, i tried that, but since I need to bind the fields to the URL., it
gives me an error, to start the page because they are not defined to begin
with.

So would I have to <cfparam> each field first, which should start them all
at "", and then set them using the URL's value if the username is taken?


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 13, 2006 Jul 13, 2006

Copy link to clipboard

Copied

You could cfparam them. It's probably the easiest way.

<cfparam name = "url.field1" default = "">
dot dot dot
<cfinput name="field1" value="#url.field1#">

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 13, 2006 Jul 13, 2006

Copy link to clipboard

Copied

LATEST
That's what I thought it would come down to. Thanks. Didn't know if there
was an easier way.

In ASP you just bind the text box to Request.QueryString. Didn't see
anything like that in Coldfusion.


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation