ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 30th, 2004, 07:47 PM
Alas's Avatar
Alas Alas is offline
Wickedwd.com
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Location: wickedwd.com
Posts: 187 Alas Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 17 h 32 m 22 sec
Reputation Power: 0
Post Initial Values

ok heres the situation,

i created a login and login check it works. yeah me.

Problem: the login takes you to a form that begins empty. This is ok if its the 1st time the person fills out form, but what i want to do is if the person already filled out the form then their data will already be filled.

My attempts are heading towards making the initial value being set to something like setting up a CFQUERY

Code:
<CFQUERY DATASOURCE="DB1" NAME="info"
SELECT FirstName
FROM Client
WHERE Username='Form.Username'
   AND Password='Form.Password'
ORDER BY FirstName
</CFQUERY>



then i would set up initial value by saying something like #info.FirstName#

ok good but the thing is the Form for login was on the previous page how do i make that info be retained for this page to be able to utilize 'Form.Username' ?

Reply With Quote
  #2  
Old June 30th, 2004, 09:27 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,689 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 16 h 33 m 51 sec
Reputation Power: 53
First, I can understand pre-populating the user name, but isn't it a bit dangerous to populate the password field, in case someone else is using the person's computer?

But anyway, you could just set cookies to persist the information. Check out CFCOOKIE. Then, your page can first check to see if the cookie is set and if it is, to populate the form values with the cookie data. Otherwise just set the form fields to blank strings.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian.
How to Post a Question in the Forums

Reply With Quote
  #3  
Old July 1st, 2004, 07:52 PM
Alas's Avatar
Alas Alas is offline
Wickedwd.com
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Location: wickedwd.com
Posts: 187 Alas Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 17 h 32 m 22 sec
Reputation Power: 0
Question Tried it but no go

I used <CFSET COOKIE.GA = #Form.Username#> in the login form. then in the form page i used
Code:
<CFQUERY DATASOURCE="DB1" NAME="profile">
SELECT FirstName
FROM Client
WHERE Username='#COOKIE.GA#'
ORDER BY FirstName

i thought this would prepopulate the form if this is the 2nd or + times the person comes to fill it out. I need their username so that the form will know whose info to use to prepopulate the form

It works the first time i start the application but when i close the browser and try again it cant find the cookie.

Have no clue, but kiteless i saw another thread, http://forums.devshed.com/showthread.php?t=139710, where the guy used hidden values, is that another way to go?

PS just guessing here but since im trying to take info from 1 form to another form, #Form.Username# is used by both forms maybe it gets confused?

Reply With Quote
  #4  
Old July 2nd, 2004, 08:21 AM
bfolger71 bfolger71 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Boston, MA
Posts: 47 bfolger71 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 34 sec
Reputation Power: 6
Your current syntax for setting the cookie is not correct. The way you have it now, you're actually creating a non-persistent structure called "COOKIE", and a variable within that structure called "GA". This explains why it's not working on subsequent visits.

As kiteless mentioned, try <cfcookie>.

<cfcookie name="GA" value="#Form.Username#">

Then try your page again.

Reply With Quote
  #5  
Old July 2nd, 2004, 09:30 AM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,689 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 16 h 33 m 51 sec
Reputation Power: 53
bfolger is right, you need to use the <cfcookie> tag (which, as he noted, I said in my earlier post ).

Reply With Quote
  #6  
Old July 3rd, 2004, 11:21 PM
Alas's Avatar
Alas Alas is offline
Wickedwd.com
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Location: wickedwd.com
Posts: 187 Alas Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 17 h 32 m 22 sec
Reputation Power: 0
Thumbs up Dumb mistake

Ok i got it, thanks for the nudge in the right direction i used a cookie like u said, but the problem wasnt saying CFCOOKIE it was fine the way i set it up, the problem was (THIS IS FOR ALL U NOOBS OUT THERE, DONT MAKE THIS MISTAKE) you ready, well *cough* i CFINCLUDEed the template where the cookie was going. Not exactly sure why thats bad, but as soon as i erased that portion of the code my application consistently worked. Why? i have no freakin clue, but whatever...it works, thx again for the cookie idea. Just in case anybody can use it heres a piece of the code.

First u set up the cookie on another page in my case the 1st form

Code:
<CFSET COOKIE.HE = '#Form.Username#'>


then on your 2nd page where u want the info to be repopulated u do something like this

Code:
<CFQUERY DATASOURCE="DB1" NAME="genesis">
SELECT * FROM Client
WHERE Client.Username = '#COOKIE.HE#'
</CFQUERY>

<!--- Alas rules!!! --->

<CFIF (NOT IsDefined("SESSION.Alas")>

  <CFSET SESSION.Alas = StructNew()>
     <CFSET SESSION.Alas.FirstName  = "#genesis.FirstName#">
  <CFSET SESSION.Alas.LastName   = "#genesis.LastName#">
</CFIF>


Happy 4th of July to all

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Initial Values


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT