Solved

Passing Form Vars To Final Page

Posted on 2011-09-10
6
227 Views
Last Modified: 2012-05-12
I'm not sure if the problem is in my Application.cfm or what but there's not too much to it because I'm really not hosting a ColdFusion site in this case- only using my CF server for a single form/mailer/database entry. The best way to see whats happening is to go to apelectricservices.com and use the "Text-A-Tek" form on the right. You will see that the only the 1st entry, Name:, is being displayed as the results on the final, thanks.cfm. This is also the only variable being inserted into the database.... It use to work. Maybe my code is so brilliant that it grew it's own personality and decidsed to change itself? Far from it LOL. I know just enough to get into trouble.
App.cfm
<cfapplication name="MyApp"  clientmanagement="No"
                    sessionmanagement="Yes"
                    sessiontimeout="#CreateTimeSpan(0,0,15,0)#"
                    applicationtimeout="#CreateTimeSpan(0,2,0,0)#">
                    
                   <!---<cfset request.dsn="apecdb1sql">--->
<cfset apec ="apecdb1sql">
<!---<cfset imageCFC = createObject("component","com.image")>--->
<cfset root = "#ExpandPath(".")#">
<cfset images = "#root#\images">
<!---<cfset tPath = "#iPath#\temp">
<cfset logoPath = "#ipath#\member_logo">--->


<!--- TURN DEBUGGING ON AND OFF HERE (TRUE / FALSE) --->

<cfset session.debug = false>
<cfif session.debug eq true><br><br>
<cflock timeout=20 scope="Session" type="Readonly">
<cfdump var="#StructKeyList(Session)# " label="StructKeyList Session">
<cfdump var="#StructKeyList(Application)# " label="StructKeyList Application">

<!--- <cfdump var="#cgi.HTTP_HOST#" label="#cgi.HTTP_HOST#">--->
  
</cflock>

<!---<cfdump var="#expandpath(".")#\#url.id#" label="Expand Path">--->
</cfif>
<!--- CATCH ANY CF ERRORS AND GIVE THE USER A NICE ERROR MESSAGE
            AS OPPOSED TO A CF ERROR WHEN NOT IN DEBUG MODE --->
<!---<cfif NOT session.debug>
      <cferror type="exception" template="error.html">
</cfif>--->



 <!--- <cfset Session.file = file>--->
  <!---<cfset session.form = form>--->
<!---PARAMS- Note to self: Use sparingly for queries only if possible.--->
<cfparam  name="form.name" default="">
<cfparam  name="form.location" default="">
<cfparam  name="form.phone" default="">
<cfparam  name="form.email" default="">
<cfparam  name="form.comments" default="">
<cfparam  name="form.service" default="">


rightbarForm.js
// JavaScript Document

// <!-- Begin
document.write(' <form action="/Includes/APmailer1.cfm" method="get">');
document.write('<fieldset>');
document.write('<div><span class="style14">Text-A-Tech-Now!</span></div>');
document.write('<input name="_recipients" type="hidden" value="andy@apelectricservices.com,813312....@messaging.sprintpcs.com,rowehl@aol.com,813625....@vtext.com" />');

   //test line
//document.write('<input name="_recipients" type="hidden" value="" />');
   //test line
document.write('<input name="_requiredFields" type="hidden" value="Name","Phone" />');
/* document.write(' <input name="_redirectUrl" type="hidden" value="Includes/thanks.cfm" />');*/
document.write('<ol>');
document.write('<label for="password"></label><input id="password" name="password" type="hidden" value= "111" />');
document.write('<li><label for="Name">Name:</label> <input id="Name" name="Name" class="text" type="text" /></li>');
document.write('<li><label for="City">City</label> <input name="location" type="text" /></li>');
document.write('<li><label for="phone">Phone:</label> <input id="phone" name="phone" class="text" type="text" /></li>');
document.write('<li><label for="email">Email(not required):</label> <input id="email" name="Email" class="text" type="text" /></li>');
document.write('<li><label>Message</label> <textarea name="Comments" rows=2 cols=16></textarea></li>');
document.write('<li><label>Service:</label> <select name="Service" class="text">');
document.write('<option value="EmergencyService">Emergency</option>');
document.write('<option value="ServiceCall">Service Call</option>');
document.write('<option value="Install">Installation</option>');
document.write('<option value="Remodel">Remodel</option>');
document.write('<option value="ServiceUpgrade">Service Upgrade</option>');
document.write('<option value="Systems">Fire Alarm/ Other</option>');
document.write('<option value="Estimate">Estimate</option>');
document.write('</select></li>');
document.write('</ol>');
document.write('<input type="submit" name="submit" class="submit" value="Send Text Now!" /></fieldset>');
document.write('</form>	');
//  End -->

APmailer1.cfm:
<!--- Only Security Needed Is IP Address---> 
<cfif NOT isDefined("Form.submit") AND password NEQ "111" AND CGI.HTTP_HOST NEQ 'apelectricservices.com'> 
<!--- Redirect To An Error Invalid Page Access --->
<cflocation url="../error.cfm?FirstName=UNAUTHORIZED&nbsp;ACCESS!" addtoken="no">
<cfexit method='EXITTEMPLATE'> 
<cfelse><!---GOOD SERVER_NAME--->
<cfset phone = rereplace(phone, "[^0-9]", "", "all") /> 
<cfif isDefined ('phone') AND Len(phone) GTE 7 >
<cftransaction>
<cfmail to = "813312....@messaging.sprintpcs.com"
   cc="813625....@vtext.com"
   bcc="andy@apelectricservices.com; rowehl@.com; horace@apelectricservices.com"
from = "switchboard@apelectricservices.com"
Subject = "#Name#">
Number:#phone#;
Location:#location#;
Inquiry:#service#;
Message: #comments#;
Email: #email#
</cfmail>
</cftransaction>
<cflocation url="thanks.cfm?name=#name#&amp;location=#location#&amp;phone=#phone#&amp;email=#email#&amp;comments=#comments#&amp;service=#service#" addtoken="no">
	<cfelse>
  
	<cflocation url="../error.cfm?FirstName=ERROR&nbsp;ON&nbsp;FORM&nbsp;DATA!" addtoken="no">
	
</cfif><!--- MISSING DATA--->
</cfif><!--- SERVER_NAME--->

You can just view the source on thanks.cfm

Open in new window

0
Comment
Question by:A_AmericanELectric
  • 3
  • 2
6 Comments
 
LVL 39

Expert Comment

by:gdemaria
ID: 36517895
can you turn on debugging and show the actual error you're getting along with the lines of code associated with the error.  I tested the form and it just says "Error on the Form"... need more info.
0
 
LVL 52

Accepted Solution

by:
_agx_ earned 250 total points
ID: 36517925
@gd - I think it's just his server side validation message.   Try entering something like looks like a real phone number ie (800) 555-5555. Then you should get to the "Thank You" page:

ie
You have submitted the following data to at least one of our trucks:
Name: name
Location:
Phone:
Email:
Comment:
Service:


I don't have time to delve into it right now. But one oddity I noticed is the cflocation to the thank you page.  I don't think it's passing the variables correctly.  

ie <cflocation url="thanks.cfm?name=#name#&amp;location=#location...

Night :)
0
 

Author Comment

by:A_AmericanELectric
ID: 36517953
Yes that is the problem. My cel is receiving your data just fine but it stops at mailer1.cfm. The variables stop after being mailed and do not go to thanks.cfm therefore do not get inserted into db
0
Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

 

Author Comment

by:A_AmericanELectric
ID: 36517959
actually the varibale #name", the 1st variable passes all the way through but the others (city etc.) get texted and emailed but stop there. I think its some conflict with Application.cfm and the way I'm passing them through cflocation
0
 
LVL 39

Assisted Solution

by:gdemaria
gdemaria earned 250 total points
ID: 36517983
try changing all the  &amp;  to just &   in your cflocation

I believe this is what agx was suggesting...

0
 

Author Closing Comment

by:A_AmericanELectric
ID: 36518013
Worked great! Thanks to both of you!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
CFIf Syntax and Logic 27 55
Scroll 5 news at a time. 4 33
xss alert in domino url 9 32
Finding the file/plugin that inserted my Google Analytics code? 7 33
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo‚Ķ
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question