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:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old August 3rd, 2004, 12:41 PM
elise_driver elise_driver is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: Norwich
Posts: 53 elise_driver User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 27 m 10 sec
Reputation Power: 5
Question adding to database using info from form 1

I have passed parameters from form 1 to form 2 successfully but when I submit from page2 it doesn't add the text to the SQL database.

Page2: (This does get the parameters from page1 ok)


<cfset CurrentPage=GetFileFromPath(GetTemplatePath())>
<cfif IsDefined("FORM.MM_InsertRecord") AND FORM.MM_InsertRecord EQ "userSignup1">
<cfquery datasource="bernada_golf">
INSERT INTO dbo.tbPlanetLogin (emailaddress, firstname, lastname) VALUES (
<cfif IsDefined("FORM.emailaddress") AND #FORM.emailaddress# NEQ "">
'#FORM.emailaddress#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.firstname") AND #FORM.firstname# NEQ "">
'#FORM.firstname#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.lastname") AND #FORM.lastname# NEQ "">
'#FORM.lastname#'
<cfelse>
NULL
</cfif>
)
</cfquery>

</cfif>




<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
Page 2<p>
<cfoutput>
<form name="userSignup1" action="<cfoutput>#CurrentPage#</cfoutput>" method="post">
Data from form 1: #form.emailaddress#<br>
Data from form 1: #form.firstname#<br>
Data from form 1: #form.lastname#<br>
Data from form 1: #form.password#<br>
<input type="hidden" name="emailaddress" value="#form.emailaddress#">
<input type="hidden" name="firstname" value="#form.firstname#">
<input type="hidden" name="lastname" value="#form.lastname#">
<input type="hidden" name="password" value="#form.password#">

<input type="submit" value="Sign up">
</form>
</cfoutput>
</body>
</html>

Reply With Quote
  #2  
Old August 4th, 2004, 09:28 AM
Ebot's Avatar
Ebot Ebot is offline
Meatball Surgeon
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2004
Location: Elbow deep in code
Posts: 1,163 Ebot User rank is Brigadier General (60000 - 70000 Reputation Level)Ebot User rank is Brigadier General (60000 - 70000 Reputation Level)Ebot User rank is Brigadier General (60000 - 70000 Reputation Level)Ebot User rank is Brigadier General (60000 - 70000 Reputation Level)Ebot User rank is Brigadier General (60000 - 70000 Reputation Level)Ebot User rank is Brigadier General (60000 - 70000 Reputation Level)Ebot User rank is Brigadier General (60000 - 70000 Reputation Level)Ebot User rank is Brigadier General (60000 - 70000 Reputation Level)Ebot User rank is Brigadier General (60000 - 70000 Reputation Level)Ebot User rank is Brigadier General (60000 - 70000 Reputation Level)Ebot User rank is Brigadier General (60000 - 70000 Reputation Level)Ebot User rank is Brigadier General (60000 - 70000 Reputation Level)Ebot User rank is Brigadier General (60000 - 70000 Reputation Level)  Folding Points: 21785 Folding Title: Starter FolderFolding Points: 21785 Folding Title: Starter Folder
Time spent in forums: 1 Week 4 Days 3 h 34 m 39 sec
Reputation Power: 684
What your doing looks ok.

Try removing the validating of the form values and just assume that they are ok (or just do a quick cfoutput of them)

it would probably be a lot cleaner code as well if your just used cfparam to set the default values of your form values to null instead of having a bunch of if statements in your query.

Reply With Quote
  #3  
Old August 4th, 2004, 12:59 PM
elise_driver elise_driver is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: Norwich
Posts: 53 elise_driver User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 27 m 10 sec
Reputation Power: 5
still having problems

If I leave <cfoutput> tags around the hidden fields it puts #form.emailaddress# for example into the database. If I remove the <cfoutput> tags it doesn't put anything in the database.

Is there something else I can use instaed of #form.emailaddress# for the value in the hidden field or has anyone got any other suggestions.

Cheers

peter

Form code:

<form name="userSignup1" action="<cfoutput>#CurrentPage#</cfoutput>" method="post">
<cfoutput>
<input type="hidden" name="emailaddress" value="#form.emailaddress#">
<input type="hidden" name="firstname" value="#form.firstname#">
<input type="hidden" name="lastname" value="#form.lastname#">
<input type="hidden" name="password" value="#form.password#">
</cfoutput>
<input type="submit" value="Sign up">

<input type="hidden" name="MM_InsertRecord" value="form1">
</form>

Reply With Quote
  #4  
Old August 4th, 2004, 02:37 PM
elise_driver elise_driver is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: Norwich
Posts: 53 elise_driver User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 27 m 10 sec
Reputation Power: 5
Lightbulb solution

In case this is of use to other developers the solution is uou must have the <cfoutput> tags outside the form. Then it works ok.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > adding to database using info from form 1


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 5 hosted by Hostway