Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing Parameters

Status
Not open for further replies.

joetadalan

Programmer
Oct 3, 2002
5
0
0
US
I am new to ColdFusion and this is my problem -

I have created a login screen -
User Name
Password
Confirm Password

Once that has been Validated -
I bring up a new information screen - general information
with the User Name being brought over as a display only field -

The problem occurs when I try and validate the data entered - I lose the UserName field -

Here is part of the code -
<FORM ACTION=&quot;submit2.cfm?UserName=#UserName#&quot; method=POST>
<PRE>
<cfoutput>
<input type=&quot;hidden&quot; name=&quot;UserName&quot; Value=&quot;#UserName#&quot;>
<b>User Name: #URL.UserName#</b><br><br>
</cfoutput>

Title: <select Name=&quot;prefix&quot; Value=&quot;<cfoutput>#form.prefix#</cfoutput>&quot;>
<option>MR.
<option>MRS.
<Option>Ms.
<Option>Miss
</select>
First Name: <input type=&quot;text&quot; NAME=&quot;FirstName&quot; Size=&quot;10&quot; MaxLength=&quot;25&quot; Value=&quot;<cfoutput>#form.FirstName#</cfoutput>&quot;> M.I.: <input type=&quot;text&quot; Name=&quot;MiddleName&quot; size=&quot;1&quot; MaxLength=&quot;1&quot; Value=&quot;<CFOUTPUT>#form.MiddleName#</CFOUTPUT>&quot;> Last Name:<input type=&quot;text&quot; NAME=&quot;LastName&quot; size=&quot;15&quot; MaxLength=&quot;30&quot; Value=&quot;<CFOUTPUT>#form.LastName#</CFOUTPUT>&quot;>
Suffix: <input type=&quot;text&quot; NAME=&quot;Suffix&quot; size=&quot;2&quot; MaxLength=&quot;2&quot; Value=&quot;<CFOUTPUT>#form.Suffix#</CFOUTPUT>&quot;>
<p>

<b>Mailing Address:</b>
Address Information is for informational purposes only and is not required.<br>
Street Address:<input type=&quot;text&quot; NAME=&quot;StNumber&quot; Size=&quot;10&quot; MaxLength=&quot;15&quot; Value=&quot;<CFOUTPUT>#form.StNumber#</CFOUTPUT>&quot;> <input type=&quot;Text&quot; NAME=&quot;StName&quot; Size=&quot;15&quot; MaxLength=&quot;25&quot; Value=&quot;<CFOUTPUT>#form.StName#</CFOUTPUT>&quot;> <input type=&quot;Text&quot; NAME=&quot;StType&quot; Size=&quot;2&quot; MaxLength=&quot;10&quot; Value=&quot;<CFOUTPUT>#form.StType#</CFOUTPUT>&quot;>
City: <input type=&quot;Text&quot; NAME=&quot;City&quot; Size=&quot;10&quot; MaxLength=&quot;25&quot; Value=&quot;<CFOUTPUT>#form.City#</CFOUTPUT>&quot;> State: <input type=&quot;Text&quot; NAME=&quot;State&quot; size=&quot;2&quot; MaxLength=&quot;5&quot; Value=&quot;<CFOUTPUT>#form.State#</CFOUTPUT>&quot;>
Zip Code: <input type=&quot;Text&quot; NAME=&quot;PostalCode&quot; size=&quot;5&quot; MaxLength=&quot;15&quot;>
<p>

<b>Other Contact Information:</b>
Other Contact Information is for informational purposes only and is not required.<br>
Phone: <input type=&quot;Text&quot; NAME=&quot;HomePhone&quot; Value=&quot;<CFOUTPUT>#form.HomePhone#</CFOUTPUT>&quot;>
Alt Phone: <input type=&quot;Text&quot; NAME=&quot;WorkPhone&quot; Value=&quot;<CFOUTPUT>#form.WorkPhone#</CFOUTPUT>&quot;>
<p>
E-mail Address: <input type=&quot;Text&quot; NAME=&quot;EmailAddress&quot; Value=&quot;<CFOUTPUT>#form.EmailAddress#</CFOUTPUT>&quot;>
</PRE>
<input type=&quot;Submit&quot;>
</FORM>

In the First Statement - Form - is that where the problem is -

Any help is greatly appreciated.

 
a) The code you posted mixes FORM variables and URL variables on the same page. Since you have lots of FORM variables in your code, I'm assuming you're doing a POST to this page... which means all variables would be FORM.xxx
So you'd want to change the UserName section to
Code:
<cfoutput>
<input type=&quot;hidden&quot; name=&quot;UserName&quot; Value=&quot;#FORM.UserName#&quot;>
<b>User Name: #FORM.UserName#</b><br><br>
</cfoutput>

b) You can not add query string parameters to an action of a POST request (form). It's actually not such a good idea to add them to a GET either... but that's another story.

Remove it from your FORM tag like:
Code:
<FORM ACTION=&quot;submit2.cfm&quot; method=POST>

Since you already have a hidden input named &quot;UserName&quot; (as above), it will get passed to submit2.cfm as a FORM variable.

Hope it helps,
-Carl
 
It's kind of unclear where you are losing the UserName variable. Do you have it from the login screen and then lose it when the form you posted is submitted?

I think it's because you are passing what is essentially a URL parameter in your form action string, but using a POST method on it.

Take the parameter off of the form action since you have it in a hidden FORM field anyways. Then you will be able to use the FORM.Username variable.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top