Solved

Passing Form Vars To Final Page

Posted on 2011-09-10
6
222 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
This video teaches users how to migrate an existing Wordpress website to a new domain.

758 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now