Hi guys!
I need your help!
The next script is a normal “insert page” which get back the “GENERATED_KEY”: “myid” and put it hidden form:”myid”.
If the value of “myid” is numeric then the action attribute of “form1” get a page address as value.
The issue is, it shows 2 times the insert page. You have to push 2 times the “submit” button to receive the desired page.
Is it a way to shortcut these repetitive submit?
<cfparam name="email" default="">
<cfparam name="lname" default="">
<cfparam name="fname" default="">
<cfparam name="myAdress" default="">
<cfparam name="myid" default="">
<cfif isNumeric("#myid#")>
<cfset myAdress ="workform.cfm">
<cfelse>
<cfif isDefined("form.email")>
<cfquery datasource="myData" result="myid">
INSERT INTO myTable
(email, lname, fname)
VALUES
('#form.email#', '#form.lnume#', '#form.fname#')
</cfquery>
<cfset #form.myid#="#myid.GENERATED_KEY#">
<cfdump label="Result Structrure" var="#form#"/>
</cfif>
</cfif>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" />
<title>Register</title>
</head>
<body>
<cfform name="form1" id="form1" method="post" preservedata="yes" action="#myAdress#">
</p>
<p>
<label for="email">Email:</label>
<cfinput type="text" name="email" id="email">
</p>
<p>
<label for="lname">Last name:</label>
<cfinput type="text" name="lname" id="lname">
</p>
<p>
<label for="fname">First name</label>
<cfinput type="text" name="fname" id="fname">
</p>
<p>
<cfinput type="hidden" name="myid">
<cfinput type="submit" name="submit" id="submit" value="OK!">
</p>
</cfform>
<p> </p>
</body>
</html>