|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
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' ? |
|
#2
|
|||
|
|||
|
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 |
|
#3
|
||||
|
||||
|
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? |
|
#4
|
|||
|
|||
|
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. |
|
#5
|
|||
|
|||
|
bfolger is right, you need to use the <cfcookie> tag (which, as he noted, I said in my earlier post
). |
|
#6
|
||||
|
||||
|
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 |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > Initial Values |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|