I have the following ColdFusion code on a server (which I'm not able to change) :
<cfquery name="getlogin" datasource="#application.dsn#">
SELECT *
FROM tbl_userAccount
WHERE userName = <cfqueryparam cfsqltype="cf_sql_varchar" value="#form.userName#"/> AND passWord = <cfqueryparam cfsqltype="cf_sql_varchar" value="#form.passWord#"/> AND siteID = <cfqueryparam cfsqltype="cf_sql_integer" value="#application.siteID#"/>
</cfquery>
and I'开发者_开发问答m trying to build a JavaScript window for logging into it from an Adobe AIR app.
Specifically, I want it to send the user credentials (uName and pWord), and bring back the account ID (which would also be included in the 'SELECT *' statement).
Can anyone help me get started with this?
A really quick dirty way to get started with this to drop that query into a method in a CFC.
That method would take two parameters for username and password. Replace the form variables in the cfqueryparms with the appropriate arguments on your method.
On the method you should set the return type as numeric and the returnttype as json. You'll be able to call the method in the CFC from an Ajax post accepting back the account id. Basically just use the CFC as a webservice.
Things you'll need to do are validating the username and password, returning zero or a negative number if you don't get a single record returned by your query, take the * out of the select and only return the account id.
精彩评论