I have a page with this basic process:
Click checkboxes next to forms you want to download
Click submit
CFWindow pops up to collect some basic info
Click submit to download forms while staying in the window that was opened by CFWindow
When you click the submit button inside the CFWindow , it brings you back to the parent page. I want the form submission to stay inside the CFWindow. I saw this post: Refresh cfwindow content. However, the refreshOnShow = "true" does not work. Every time I hit submit, it goes back to the parent window.
Here is the Parent page:
<cfform name="myform">
<cfinput type="hidden" name="OrgID" value="#getit.orgID#">
<table width="95%" border="0" cellspacing="5" cellpadding="0" align="center">
<tr>
<td width="50%" valign="top" class="coretextforBR">
<cfinput type="checkbox" name="GetThese" value="#form_ID#">
<a class="corelinkforBR">#Forms_Name#</a>
<br /><br />
#Forms_Description#
<br /><br />
</td>
</tr>
<tr>
<td width="50%" valign="top" class="coretextforBR">
<cfinput type="checkbox" name="GetThese" value="#form_ID#">
<a class="corelinkforBR">#Forms_Name#</a>
<br /><br />
#Forms_Description#
<br /><br />
</td>
</tr>
<tr>
<td width="50%" valign="top" class="coretextforBR">
<cfinput type="checkbox" name="GetThese" value="#form_ID#">
<a class="corelinkforBR">#Forms_Name#</a>
<br /><br />
#Forms_Description#
<br /><br />
</td>
</tr>
<tr>
<td colspan="2">
<input type="submit"value="Get It" onclick="javascript:ColdFusion.Window.show('mywindow1')">
</td>
</tr>
</table>
</cfform>
<cfwindow x="250" y="250" width="400" height="400"
name="mywindow1" title="Almost ready to download" initshow="false" draggable="false" resizable="false"
refreshOnShow="true" source="submitform.cfm?GetThese={myform:GetThese.value}&OrgID={myform:OrgID}&action=information"
bodystyle="background-color: white;" headerStyle="background-color: ###getcss.color#; font-family: #getcss.font#; color: ###getcss.fontcolor#;" />
Here is the source (submit.cfm) for the CFWwindow:
<cfparam name="attributes.action" default="information">
<cfoutput>
<html>
<head>
<style type="text/css">
</style>
</head>
<body>
This window will collect information to begin download
<br>
<!--- action for downloading --->
<cfif attributes.action eq "download">
<cfloop info and stuff left out>
#Forms_Name#<br />
</cfloop>
<!--- what you see when page initially loads --->
<cfelse>
<form action="submitform.cfm?action=download" method="post">
<input type="hidden" name="GetThese" value="#attributes.GetThese#">
<input type="hidden" name="OrgID" value="#attributes.OrgID#">
<table width="95%" border="0" align="center">
<tr>
<td class="coretextforBR">First:</td>
<td><input type="text" name="CollectedInfo_First"></td>
</tr>
<tr>
<td class="coretextforBR">Last:</td>
<td><input type="text" name="CollectedInfo_Last"></td>
</tr>
<tr>
<td class="coretextforBR">Phone:</td>
<td><input type="text" name="CollectedInfo_Phone"></td>
</tr>
<tr>
<td class="coretextforBR">Email:</td>
<td><input type="text" name="CollectedInfo_Email"></td>
</tr>
<tr>
<td class="coretextforBR">Best way <br> to contact:</td>
<td><input type="text" name="CollectedInfo_BestWay"></td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="Download" class="button one"></td>
</tr>
</table>
</form>
</cfif>
</cfoutput>
</body>
</html>
I have no idea what I am doing wrong. I couldn't find a definite answer to my problem either other than the refreshOnShow. Should I rethink and do a ajax submit?
Using <cfform> instead of normal <form> worked as Liegh suggested.
Related
I have been searching all over for a way to only translate the contents of a text box.... but I can only find ways to translate the entire website.
Below is a sample of the page code of the form we'll be submitting. I would like to just translate the contents of textarea name="emergency_procedures".
<form action="#cgi.script_name#?submit=<cfif url.id neq "">UPDATE&id=#url.id#<cfelse>YES</cfif>" method="post">
<table id="keywordEditTable" class="editTable" cellpadding="0" cellspacing="0">
<tr>
<td class="editLabel"><span>*</span>Type Title:</td>
<td class="editField">
<input type="text" name="name"<cfif url.id neq "">value="#trim(item.name)#"</cfif> size="35" />
</td>
</tr>
<tr>
<td class="editLabel"><span>*</span>Active:</td>
<td class="editField">
<input type="radio" name="active"<cfif url.id eq "" or item.active eq 1> checked="checked"</cfif> value="1" />
<label for="active">Yes</label>
<input type="radio" name="active"<cfif url.id neq "" and item.active neq 1> checked="checked"</cfif> value="0" />
<label for="active">No</label>
</td>
</tr>
<tr>
<td class="editLabel"><span>*</span>Default:</td>
<td class="editField">
<input type="radio" name="is_default"<cfif url.id eq "" or item.is_default eq 1> checked="checked"</cfif> value="1" />
<label for="active">Yes</label>
<input type="radio" name="is_default"<cfif url.id neq "" and item.is_default neq 1> checked="checked"</cfif> value="0" />
<label for="active">No</label>
</td>
</tr>
<tr id="editLastRow">
<td class="editLabel">Emergency Procedures:</td>
<td class="editField"><textarea name="emergency_procedures" cols="67" rows="15"><cfif url.id neq "">#item.emergency_procedures#</cfif></textarea></td>
</tr>
<cfif url.id neq "">
<tr id="editLastRow">
<td class="editLabel"></td>
<td class="editField">
</td>
</tr>
</cfif>
<tr>
<td class="editLabel"><span>*</span>Notify URL:</td>
<td class="editField">
<input type="text" name="notify_url"<cfif url.id neq "">value="#item.notify_url#"</cfif> size="65" />
</td>
</tr>
<tr>
</tr>
<tr>
<td></td>
<td id="editButtons">
<input type="submit" name="Make" value="<cfif url.id neq "">Update<cfelse>Create</cfif>" id="editButton" />
<cfif url.id neq "">
<input type="button" name="Delete" value="Delete" id="deleteButton" onclick="confirmDelete()" />
<input type="hidden" name="id" value="#url.id#" />
</cfif>
<input type="button" name="Cancel" value="Cancel" id="cancelButton" onclick="document.location='EMB_types.cfm'" />
</td>
</tr>
</table>
</cfoutput>
This is too long for a comment, but here goes. You want to use Google's REST API and / http. I haven't programmed out all the details but this should get you started
<cfscript>
endpoint = "https://translation.googleapis.com/language/translate/v2";
if (cgi.request_method == "POST") {
httpService = new http();
httpService.setMethod("post");
httpService.setCharset("utf-8");
httpService.setUrl(endpoint);
httpService.addParam(type="formfield", name="q", value= form.emergency_procedures);
httpService.addParam(type="formfield",name="target",value="yourlanguage");
httpService.addParam(type="formfield",name="key",value="yourkey");
result = httpService.send().getPrefix();
writedump(result);
}
</cfscript>
You are probably going to have tinker with the fields to get to work right. Currently the REST API documentation is at: https://cloud.google.com/translate/docs/reference/rest/v2/translate
I have a form which takes in the values of First Name, Last Name and DOB. I have two tables: TableA and TableB. Each table may contain information of the person name that is entered in the form. What I would like to do, in ColdFusion, write a query where I take the user inputs and compare which Table contains the info. Once I find which table contains the user info, display particular columns that pertain in that table.
Below is the form:
<Form name="ERHospital" Method="Post" class="a">
<div align="center" style="margin-top:10pt; margin-bottom:10pt">
<table Border="0" width="100%" align="center" cellpadding=0 cellspacing=0 >
<tr>
<td class="m" id="fName">First Name </td>
<td>
<input class="a" id="FirstName" name="FirstName" value="<cfoutput></cfoutput>" size="15">
</td>
<td class="m" id="lName">Last Name </td>
<td>
<input class="a" id="LastName" name="LastName" value="<cfoutput></cfoutput>" size="15">
</td>
<td class="m" id="DOB">
DOB<br />
<font color="##CC0000" size="1" style="italic">(mm/dd/yyyy)</font>
</td>
<td>
<input type="text" id="BirthDt" name ="BirthDt" id="BirthDt" maxlength="10" size="10">
</td>
</tr>
<tr>
<!---<td class="m" id="Hospital">Hospital</td>
<td>
<select name="hosp" id="hosp"></select>
</td>--->
<!---<td class="m" colspan="2"></td>
<td class="m">
<input type="button" value="Submit" onClick="SubmitMe(); checkFields();" name="SubmitEmpBtn" style="font-size:12px; font-family:Arial, Helvetica, sans-serif; font-weight:bold">
</td>
<td align="left">
<input type="button" name="Clear" value="Clear" onClick="ClearForm()" style="font-size:12px; font-family:Arial, Helvetica, sans-serif; font-weight:bold">
</td>
</tr>--->
</table>
<div style="text-align:center; margin-top:15pt"><input type="button" value="Submit" onClick="SubmitMe(); checkFields();" name="SubmitEmpBtn" style="font-size:12px; font-family:Arial, Helvetica, sans-serif; font-weight:bold"> <input type="button" name="Clear" value="Clear" onClick="ClearForm()" style="font-size:12px; font-family:Arial, Helvetica, sans-serif; font-weight:bold"> </div>
<!---<table align="center">
<TR>
<TD align="center"><input type="button" value=" Submit " onClick="SubmitMe()" name="SubmitEmpBtn" style="font-size:14px; font-family:Arial, Helvetica, sans-serif"> <input type="button" name="Clear" value=" Clear " onClick="ClearForm()" style="font-size:14px; font-family:Arial, Helvetica, sans-serif"> </td>
</tr>
</table>
</table>--->
</div>
</FORM>
If the user is guaranteed to be in only one table, then you can use a UNION ALL like the following:
<cfquery name="myquery" datasourse="#myDSN#">
SELECT <userField1>, <userField2>
FROM Table1
WHERE
FirstName = <cfqueryparam value="#form.firstname#" cfsqltype="cf_sql_varchar">
AND
LastName = <cfqueryparam value="#form.lastname#" cfsqltype="cf_sql_varchar">
UNION ALL
SELECT <userField1>,<userField2>
FROM Table2
WHERE
FirstName = <cfqueryparam value="#form.firstname#" cfsqltype="cf_sql_varchar">
AND
LastName = <cfqueryparam value="#form.lastname#" cfsqltype="cf_sql_varchar">
</cfquery>
If the user is only in one table, you'll only get the results for your requested user.
EDIT: I would also add that I am not a big fan of using form, url or any other external variable in a sql query without making sure they have been sanitized. But that is a WHOLE different type of discussion. :-)
I would like to add additional functionality to a web site including the ability for a form to only be submitted once, this is so that when the user refreshes everything is not processed again etc.
I have looked at a few pieces of code using Jquery and javascript but was wondering if there was any way to do this in Coldfusion, and how do other people who use Coldfusion do it? I am looking for the most simple yet effective solution if possible.
Below is an example of a form that I would like to disable "resubmit" funtionality:
<cfinclude template="header.cfm">
<cfparam name="form.step" default="1">
<cfparam name="form.submit" default="">
<cfparam name="form.finish" default="">
<script type='text/javascript'>
//<![CDATA[
$(document).ready(function() {
var currentItem = 1;
$('#addnew').click(function(){
currentItem++;
$('#items').val(currentItem);
var strToAdd = '<tr><td class="Copy" valign="top">Item Name:</td><td><input type="text" name="Itemname'+currentItem+'" id="Itemname'+currentItem+'" required="yes" message="Please enter a Name" class="TextBlock"></td></tr><tr><td class="Copy" valign="top">Item Description:</td><td><input type="text" name="ItemDesc'+currentItem+'" id="ItemDesc'+currentItem+'" required="yes" message="Please enter a Description" class="TextBlock"></td></tr><tr><td class="Copy" valign="top">Quantity</td><td><input type="text" name="Quantity'+currentItem+'" id="Quantity'+currentItem+'" required="yes" message="Please enter a Quantity" class="TextBlock"></td></tr><tr><td class="Copy" valign="top">Product Code:</td><td><input type="text" name="Code'+currentItem+'" id="Code'+currentItem+'" required="yes" message="Please enter a Code" class="TextBlock"></td></tr><tr><td class="Copy" valign="top">Price:</td><td><input type="text" name="Price'+currentItem+'" id="Price'+currentItem+'" required="yes" message="Please enter a Price" class="TextBlock"></td></tr>';
$('#data').append(strToAdd);
});
});
//]]>
</script>
<cfif form.finish eq "finish">
<cflocation addtoken="no" url="inv_new.cfm">
</cfif>
<form id="formID" method="post" action="inv_new.cfm" enctype="multipart/form-data">
<table border="0" cellpadding="0" cellspacing="1" width="100%" class="Border" align="center">
<tr>
<td class="CopyWhite" align="left" background="images/tab_bg.gif" colspan="2">Add a new invoice</td>
</tr>
<cfoutput>
<cfif form.step eq 1>
<cfquery name="get_vendors" datasource="#application.db#">
SELECT * FROM tblpassVendor
WHERE vendorActive = 1
AND CompanyID = #session.companyid#
AND VendorID IN (#GetAdmin.AdminVendors#)
</cfquery>
<tr>
<td class="Copy" valign="top">Invoice Using:</td>
<td>
<Select name="INVBY">
<cfloop query="get_vendors">
<option value="#vendorid#">#vendorname#</option>
</cfloop>
</Select>
</td>
</tr>
<tr>
<td class="Copy" align="center" colspan="2">
<input type="Submit" name="Submit" value="Submit" class="submitbutton">
<input type="hidden" name="step" value="2" />
<input type="Reset" name="Reset" value="Reset" class="submitbutton">
</td>
</tr>
</cfif>
<cfif form.step eq 2>
<input type="hidden" name="vendor" value="#FORM.INVBY#" />
<tr>
<td class="Copy" valign="top">Order Details:</td>
<td>
</td>
</tr>
<tr>
<td class="Copy" valign="top">Payment Due:</td>
<td>
<input type="text" id="date1" class="validate[required]" name="INVPAYMENTDATE" class="TextBlock">
</td>
</tr>
<tr>
<td class="Copy" valign="top">Reference Number:</td>
<td>
<input type="text" class="validate[required]" name="REFNUM" class="TextBlock">
</td>
</tr>
<tr>
<td class="Copy" valign="top">Invoice Details:</td>
<td>
</td>
</tr>
<tr>
<td class="Copy" valign="top">Pay Using Masterpass:</td>
<td style="color:##000">
<input type="radio" name="MASTERPASS" value="1" checked="yes"> Yes<br />
<input type="radio" name="MASTERPASS" value="0" checked="no"> No<br />
</td>
</tr>
<tr>
<td class="Copy" valign="top">Pay Using Iveri:</td>
<td style="color:##000">
<input type="radio" name="IVERI" value="1" checked="yes"> Yes<br />
<input type="radio" name="IVERI" value="0" checked="no"> No<br />
</td>
</tr>
<tr>
<td class="Copy" valign="top">Pay Using Other:</td>
<td style="color:##000">
<input type="radio" name="OTHER" value="1" checked="yes"> Yes<br />
<input type="radio" name="OTHER" value="0" checked="no"> No<br />
</td>
</tr>
<tr>
<td class="Copy" valign="top">Billing Details:</td>
<td>
</td>
</tr>
<tr>
<td class="Copy" valign="top">Name:</td>
<td>
<input type="text" class="validate[required]" name="NAME" class="TextBlock">
</td>
</tr>
<tr>
<td class="Copy" valign="top">Surname:</td>
<td>
<input type="text" class="validate[required]" name="LNAME" class="TextBlock">
</td>
</tr>
<tr>
<td class="Copy" valign="top">Tel:</td>
<td>
<input type="text" class="validate[required]" name="TEL" class="TextBlock">
</td>
</tr>
<tr>
<td class="Copy" valign="top">Email:</td>
<td>
<input type="text" class="validate[required,custom[email]]" name="EMAIL" class="TextBlock">
</td>
</tr>
<tr>
<td class="Copy" valign="top">Address line 1:</td>
<td>
<input type="text" class="validate[required]" name="ADDR1" class="TextBlock">
</td>
</tr>
<tr>
<td class="Copy" valign="top">Address line 2:</td>
<td>
<input type="text" class="validate[required]" name="ADDR2" class="TextBlock">
</td>
</tr>
<tr>
<td class="Copy" valign="top">City/Town:</td>
<td>
<input type="text" class="validate[required]" name="CITY" class="TextBlock">
</td>
</tr>
<tr>
<td class="Copy" valign="top">Province/Region:</td>
<td>
<input type="text" class="validate[required]" name="REGION" class="TextBlock">
</td>
</tr>
<tr>
<td class="Copy" valign="top">Country:</td>
<td>
<input type="text" class="validate[required]" name="COUNTRY" class="TextBlock">
</td>
</tr>
<tr>
<td class="Copy" valign="top">ZIP/Postal Code:</td>
<td>
<input type="text" class="validate[required]" name="ZIP" class="TextBlock">
</td>
</tr>
<tr>
<td class="Copy" align="center" colspan="2">
<input type="Submit" name="Submit" value="Submit" class="submitbutton">
<input type="hidden" name="step" value="3" />
<input type="Reset" name="Reset" value="Reset" class="submitbutton">
</td>
</tr>
</cfif>
<cfif form.step eq 3>
<cftry>
<cfset payuid = "#CreateUUID()#">
<cfset invuid = "#CreateUUID()#">
<!---WRITE DATA TO TBLINV--->
<cfquery name="write_inv" datasource="#application.db#" result="test">
INSERT INTO tblpassInv
(INVVENDORID,INVREF,INVNAME,INVLNAME,INVTEL,INVEMAIL,INVADDR1,INVADDR2,INVCITY,INVREGION,INVCOUNTRY,INVZIP,INVCOMPANY,INVCREATEDBY,INVDATECREATED,INVACTIVE,INVSEND,paymentuid,invuid,invmasterpass,inviveri,invother,invpaymentdate)
VALUES
(#form.vendor#,'#form.REFNUM#','#form.NAME#','#form.LNAME#','#form.TEL#','#form.EMAIL#','#form.ADDR1#','#form.ADDR2#','#form.CITY#','#form.REGION#','#form.COUNTRY#','#form.ZIP#',#session.companyid#,#session.adminid#,#createodbcdatetime(now())#,1,0,'#payuid#','#invuid#',#form.MASTERPASS#,#form.IVERI#,#form.OTHER#,'#FORM.INVPAYMENTDATE#')
</cfquery>
<cfset NewPrimaryKey = test.GENERATED_KEY>
<!---<cfinclude template="inv_amend_prods_new.cfm">--->
<tr>
<td>
<table id="data">
<tr>
<td class="Copy" valign="top">Products/Line Items:</td>
<td>
</td>
</tr>
<tr>
<td class="Copy" valign="top">Item Name:</td>
<td>
<input type="text" class="validate[required]" name="Itemname1" id="Itemname1" class="TextBlock">
</td>
</tr>
<tr>
<td class="Copy" valign="top">Item Description:</td>
<td>
<input type="text" class="validate[required]" name="ItemDesc1" id="ItemDesc1" class="TextBlock">
</td>
</tr>
<tr>
<td class="Copy" valign="top">Quantity</td>
<td>
<input type="text" class="validate[required,custom[number]]" name="Quantity1" id="Quantity1" class="TextBlock">
</td>
</tr>
<tr>
<td class="Copy" valign="top">Product Code:</td>
<td><input type="text" class="validate[required]" name="Code1" id="Code1" class="TextBlock"></td>
</tr>
<tr>
<td class="Copy" valign="top">Price: (eg. 100.00)</td>
<td><input type="text" class="validate[required,custom[number]]" name="Price1" id="Price1" class="TextBlock"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<input type="Submit" name="Submit" value="Submit" class="submitbutton">
<input type="button" id="addnew" name="addnew" value="Add new item" />
<input type="hidden" id="items" name="items" value="1" />
<input type="hidden" name="step" value="4" />
<input type="hidden" name="invid" value="#NewPrimaryKey#" />
</td>
</tr>
<cfcatch type="any">
<script type="text/javascript">
alert("An error has occured! Please try again later")
</script>
</cfcatch>
</cftry>
</cfif>
<cfif form.step eq 4>
<cftry>
<cfloop from="1" to="#FORM.items#" index="i">
<cfset thisname = form["Itemname" & i]>
<cfset thisdesc = form["ItemDesc" & i]>
<cfset thisqty = form["Quantity" & i]>
<cfset thiscode = form["Code" & i]>
<cfset thisprice = form["Price" & i]>
<cfset thisprice = replace("#thisprice#",".","","All")>
<cfquery name="add_items" datasource="#application.db#">
INSERT INTO tblpassInvItems
(invid,itemactive,itemname,itemdesc,itemqty,itemcode,itemprice)
VALUES
(#form.invid#,1,'#thisname#','#thisdesc#',#thisqty#,'#thiscode#','#thisprice#')
</cfquery>
</cfloop>
<cfset invid = form.invid>
<cfinclude template="inv_doc.cfm">
<tr>
<td class="Copy" valign="top">Display all details for invoice:</td>
<td>
</td>
</tr>
<tr>
<td class="copy" valign="top">Download</td>
<td>Download</td>
</tr>
<tr>
<td>
<input type="Submit" name="Submit" value="Submit" class="submitbutton">
<input type="hidden" id="items" name="items" value="1" />
<input type="hidden" name="step" value="5" />
<input type="hidden" name="invid" value="#form.invid#" />
</td>
</tr>
<!---<cfheader name="Content-Disposition" value="attachment;filename=#this_filename#.pdf">
<cfcontent type="application/octet-stream" file="#expandPath('.')#/dynamicdocs/#this_filename#.pdf" deletefile="No">--->
<cfcatch type="any">
<script type="text/javascript">
alert("An error has occured! Please try again later")
</script>
</cfcatch>
</cftry>
</cfif>
<cfif form.step eq 5>
<tr>
<td class="Copy" valign="top" colspan="2">Please complete the following if you would like to send the invoice now or click on finish:</td>
</tr>
<tr>
<td class="Copy" valign="top">Bcc:</td>
<td>
<cfquery name="get_vendors" datasource="#application.db#">
SELECT * FROM tblpassVendor
WHERE vendorActive = 1
AND CompanyID = #session.companyid#
AND VendorID IN (#GetAdmin.AdminVendors#)
</cfquery>
<Select name="bcc">
<cfloop query="get_vendors">
<option value="#vendorbccemail#">#vendorbccemail#</option>
</cfloop>
</Select>
</td>
</tr>
<tr>
<td>
<input type="Submit" name="Submit" value="Submit" class="submitbutton">
<input type="hidden" id="items" name="items" value="1" />
<input type="hidden" name="step" value="6" />
<input type="hidden" name="invid" value="#form.invid#" />
</td>
</tr>
<tr>
<td>Save and Start New Invoice</td>
</tr>
</cfif>
<cfif form.step eq 6>
<cftry>
<cfset invid = form.invid>
<cfinclude template="inv_mail.cfm">
<tr>
<td class="Copy" valign="top" colspan="2">Thank you! Your Invoice has been sent!</td>
</tr>
<tr>
<td class="copy" valign="top"></td>
<td>Finish</td>
</tr>
<cfcatch type="any">
<tr>
<td class="Copy" valign="top" colspan="2">An Error has occured! Your invoice has not been sent</td>
</tr>
</cfcatch>
</cftry>
</cfif>
</cfoutput>
</table>
</form>
<cfinclude template="footer.cfm">
I am not using things like cfqueryparam as this is still being developed and is within a secure environment
Thank you in advance
I used to do something like this (used it long time back, code may be off, but more of an idea):
<cfparam name="form.submitted" default=0>
<cfif structKeyExists(FORM,"submit") AND NOT FORM.submitted>
<!---action code goes here--->
<cfset form.submitted=1>
</cfif>
<form>
<!--- your other form elements--->
<input type="hidden" name="submitted" value="#FORM.submitted#">
</form>
I am not sure, it can help you much in multi-step form, but it helped in single step avoiding multi-submit by setting the flag when the form has been submitted.
You can redirect to the same page, it will avoid re-posting the form.
I have faced similar kind of situation few days back. As per my knowledge the best possible solutions are,
Redirect to some other page for preventing form resubmission.
If redirect is not suitable , the only other option is using AJAX.
I have a simple related selects issue. I have a cfdiv bound to a cfm with a select input.
The selects "work" properly in that you select a category from the first select and it changes the second select's values. But spec_id is not in the form post.
This is probably something simple. Ideas?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>CFDiv Test</title>
</head>
<body>
<cfset application.dsn = "ASA">
<cfset session.event_id = 14>
<cfif isDefined('form.specSub')>
<cfdump var="#form#"><cfabort>
</cfif>
<cfquery name="getSpecSets" datasource="#application.dsn#">
SELECT S.Setup_ID, S.Setup_Name, S.Event_ID, is_Public, is_standard,
(SELECT COUNT(Set_ID) FROM XR_Spec_Sets WHERE Setup_ID = S.Setup_ID) AS Spec_Count
FROM Spec_Sets S
WHERE S.Event_ID = 0
OR S.Event_ID = <cfqueryparam value="#session.event_ID#" cfsqltype="CF_SQL_INTEGER">
</cfquery>
<cfparam name="attributes.setup_id" default="#getSpecSets.setup_ID#">
<cfquery name="getEditName" datasource="#application.dsn#">
SELECT Setup_Name FROM Spec_Sets WHERE Setup_id = <cfqueryparam value="#val(attributes.setup_ID)#" cfsqltype="CF_SQL_INTEGER">
</cfquery>
<cfquery name="getSpecs" datasource="#application.dsn#">
SELECT XR.*, S.Spec_Name, S.Spec_Cat, S.Event_ID
FROM XR_Spec_Sets XR INNER JOIN Specs S ON XR.Spec_ID = S.Spec_ID
WHERE XR.Set_ID = <cfqueryparam value="#val(attributes.setup_ID)#" cfsqltype="CF_SQL_INTEGER">
</cfquery>
<cfquery name="getSpecCats" datasource="#application.dsn#">
SELECT Distinct(Spec_Cat) AS Spec_Cat
FROM Specs
ORDER BY Spec_Cat DESC
</cfquery>
<script>
function specSel(id) {
url = "div_specs.cfm?spec_cat=" + id;
ColdFusion.navigate(url,'spec_sel');
}
</script>
<cfoutput>
<table width="95%" align="center" cellspacing="5" border="0">
<tr>
<td width="50%">
<table cellpadding="3" width="100%" cellspacing="1" class="form">
<tr><td colspan="7" class="page_subTitle">Spec Sets</td></tr>
<tr>
<td class="grid_head">Set ID</td>
<td class="grid_head">Set Name</td>
<td class="grid_head">Event</td>
<td class="grid_head">Public</td>
<td class="grid_head">Standard</td>
<td class="grid_head" align="center">Edit</td>
<td class="grid_head" align="center">Delete</td>
</tr>
<form action="cfdivtest.cfm" method="post" name="specForm" id="specForm">
<tr>
<td class="grid_row_alt" align="center">*</td>
<td class="grid_row_alt" align="center">
<input type="text" name="setup_name" size="25" maxlength="100" class="small">
</td>
<td class="grid_row_alt" align="center">
<select name="event_IDs" class="small">
<option value="0" SELECTED>All Events</option>
<option value="#session.event_ID#">This Event Only</option>
</select>
</td>
<td class="grid_row_alt" nowrap>
<input type="radio" name="is_Public" value="Yes"> Y<br>
<input type="radio" name="is_Public" value="No" checked> N
</td>
<td class="grid_row_alt" nowrap>
<input type="radio" name="is_standard" value="Yes"> Y<br>
<input type="radio" name="is_standard" value="No" checked> N
</td>
<td class="grid_row_alt" colspan="2" align="center"><input type="submit" name="addForm" value="Add >>" class="small"></td>
</tr>
</form>
<cfloop query="getSpecSets">
<tr <cfif attributes.setup_id EQ getSpecSets.setup_id>style="font-weight:bold;"</cfif>>
<cfif getSpecSets.currentrow MOD 2 EQ 0><cfset class="grid_row_alt"><cfelse><cfset class="grid_row"></cfif>
<td class="#class#" align="center">#getSpecSets.setup_ID#</td>
<td class="#class#">#getSpecSets.Setup_Name#</td>
<td class="#class#"><cfif getSpecSets.event_id Eq 0>All Events<cfelse>This Event</cfif></td>
<td class="#class#" align="center">#getSpecSets.is_public#</td>
<td class="#class#" align="center">#getSpecSets.is_standard#</td>
<td class="#class#" align="center">
</td>
<td class="#class#" align="center">
</td>
</tr>
</cfloop>
</table>
</td>
<td width="50%">
<table cellpadding="3" width="100%" cellspacing="1" class="form">
<tr><td colspan="7" class="page_subTitle">Included Specs - #getEditName.setup_name#</td></tr>
<tr>
<td class="grid_head" width="10%"> </td>
<td class="grid_head" width="30%">Type</td>
<td class="grid_head" width="10%" align="center">Qty</td>
<td class="grid_head" width="30%">Spec</td>
<td class="grid_head" width="10%" align="center">Remove</td>
</tr>
<form action="cfdivtest.cfm?setup_ID=#attributes.setup_ID#" method="post" name="addForm" id="addForm">
<tr>
<td class="grid_row_alt" align="center">*</td>
<td class="grid_row_alt" align="center">
<select name="spec_cat" onchange="specSel(this.value)" class="small">
<cfloop query="getSpecCats">
<option value="#getSpecCats.spec_cat#" <cfif getSpecCats.currentrow EQ 1>SELECTED</cfif>>#getSpecCats.spec_cat#</option>
</cfloop>
</select>
</td>
<td class="grid_row_alt" align="center"><input type="text" name="qty" size="2" value="1" maxlength="6" class="small"></td>
<td class="grid_row_alt" align="center">
<cfdiv id="spec_sel" bind="url:div_specs.cfm?spec_cat=#getSpecCats.spec_cat[1]#"></cfdiv>
</td>
<td class="grid_row_alt" align="center" colspan="2"><input type="submit" name="specSub" class="small" value="Add >>"></td>
</tr>
</form>
<cfif getSpecs.recordcount>
<cfloop query="getSpecs">
<cfif getSpecs.currentrow MOD 2 EQ 0><cfset class="grid_row_alt"><cfelse><cfset class="grid_row"></cfif>
<tr>
<td class="#class#" align="right">#getSpecs.currentrow#. </td>
<td class="#class#">#getSpecs.spec_cat#</td>
<td class="#class#" align="center">#getSpecs.qty#</td>
<td class="#class#">#getSpecs.Spec_Name# (#getSpecs.event_id#)</td>
<td class="#class#" align="center">
</td>
</tr>
</cfloop>
<tr><td colspan="7" align="center"> </td></tr>
<cfelse>
<tr><td colspan="7" align="center"><strong><em>There are no specs assigned.</em></strong></td></tr>
</cfif>
</table>
</td>
</tr>
</table>
</cfoutput>
</body>
</html>
div_specs.cfm
<cfset application.dsn = "ASA">
<cfset session.event_id = 14>
<cfparam name="url.report" default="No">
<cfquery name="getSpecs" datasource="#application.dsn#">
SELECT Spec_name AS Option_Text, Spec_ID AS Option_Value, Event_ID
FROM Specs
WHERE 1 = 1
<cfif url.spec_cat NEQ "All">
AND Spec_Cat = <cfqueryparam value="#url.spec_cat#" cfsqltype="CF_SQL_VARCHAR">
</cfif>
AND (Event_ID = 0 OR Event_ID = <cfqueryparam value="#session.event_ID#" cfsqltype="CF_SQL_INTEGER">)
ORDER BY Spec_name
</cfquery>
<cfoutput>
<select name="spec_id" id="spec_id" class="small">
<cfif url.report EQ "Yes">
<option value="All" selected>All</option>
</cfif>
<cfloop query="getSpecs">
<option value="#getSpecs.option_value#" <cfif getSpecs.currentrow EQ 1 AND url.report EQ "No">SELECTED</cfif>>
#getSpecs.option_text#
</option>
</cfloop>
</select>
</cfoutput>
Your <form> is invalidly nested between </tr><tr>. Move it outside of the <table> tag and it should work fine.
Like this: (note stripped down for clarity)
<table width="95%" align="center" cellspacing="5" border="0">
<tr>
<td width="50%">
<form action="cfdivtest.cfm" method="post" name="specForm" id="specForm">
<table cellpadding="3" width="100%" cellspacing="1" class="form">
<tr><td colspan="7" class="page_subTitle">Spec Sets</td></tr>
<tr>
<td class="grid_head">Set ID</td>
<td class="grid_head">Set Name</td>
<td class="grid_head">Event</td>
<td class="grid_head">Public</td>
<td class="grid_head">Standard</td>
<td class="grid_head" align="center">Edit</td>
<td class="grid_head" align="center">Delete</td>
</tr>
<tr>
<td class="grid_row_alt" align="center">*</td>
<td class="grid_row_alt" align="center">
<input type="text" name="setup_name" size="25" maxlength="100" class="small">
</td>
<td class="grid_row_alt" align="center">
<select name="event_IDs" class="small">
<option value="0" SELECTED>All Events</option>
<option value="#session.event_ID#">This Event Only</option>
</select>
</td>
<td class="grid_row_alt" nowrap>
<input type="radio" name="is_Public" value="Yes"> Y<br>
<input type="radio" name="is_Public" value="No" checked> N
</td>
<td class="grid_row_alt" nowrap>
<input type="radio" name="is_standard" value="Yes"> Y<br>
<input type="radio" name="is_standard" value="No" checked> N
</td>
<td class="grid_row_alt" colspan="2" align="center"><input type="submit" name="addForm" value="Add >>" class="small"></td>
</tr>
</table>
</form>
</td>
</tr>
BTW - DON'T USE CFDIV See https://github.com/cfjedimaster/ColdFusion-UI-the-Right-Way
I have been battling with phpMyAdmin insert for sometime now,
It doesn't give me an error, yet it won't insert into the database.
My code goes like this
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="43%" id="AutoNumber1">
<tr>
<td width="100%">
<p align="left"> </td>
</tr>
<tr>
<td width="100%">
<form method="GET" name="testform" id="testform" action="logout.php">
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="69%" id="AutoNumber2" height="63">
<tr>
<td width="36%" height="22">Username</td>
<td width="64%" height="22"><input type="text" name="user" size="20"></td>
</tr>
<tr>
<td width="36%" height="22">password</td>
<td width="64%" height="22">
<input type="password" name="passwd" size="20"></td>
</tr>
<tr>
<td width="36%" height="19"> </td>
<td width="64%" height="19">
<input type="submit" value="login" name="login"></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</body>
</html>
Now the php also goes like this
<?php
require_once('inc/config.php');
$user = $_GET['user'];
$pass = $_GET['passwd'];
//database connection
$conn = mysqli_connect(DBHOST,DBUSER,DBPASS,DB);
//mysql anti injection
$username = mysql_real_escape_string($_GET['user']);
$password = mysql_real_escape_string($_GET['passwd']);
$sql = "INSERT INTO people (`username`, `password`) VALUES ('$username', '$password');";
mysqli_close($conn);
echo "Inserted";
?>
Trouble is, I don't see what I insert into the mysql database, when viewed on local host; what is the problem?
Seems like the issue might be the use of ';' twice at the end of the following line:
$sql = "INSERT INTO people (username, password) VALUES ('$username', '$password');";
Try the following.
$sql = "INSERT INTO people (username, password) VALUES ('$username', '$password');"