Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I have a suggestion form for an A-Z 1

Status
Not open for further replies.

neofactor

Technical User
Jul 30, 2000
194
US
I have a suggestion form for an A-Z Index and when I test it... submit the form, I see Double Submitions in the SQL Database. I tried it in Access and SQL and both did it... So I think it has to be the code.

Perhaps you could tell me the obvious thing I am doing wrong here:

-----------------------------------------


<CFSET pagepath = &quot;
<cfparam name=&quot;FORM.CMD&quot; default=&quot;&quot;>
<cfparam name=&quot;URL.NOTE&quot; default=&quot;&quot;>

<CFIF FORM.CMD eq &quot;Suggest&quot;>

<CFSET Error = &quot;&quot;>

<CFIF TRIM(FORM.Name) eq &quot;&quot;>
<CFSET Error = #Error# & &quot;- Missing Link Name\r&quot;>
</CFIF>

<CFIF TRIM(FORM.Url) eq &quot;&quot; or TRIM(FORM.Url) eq &quot;<CFSET Error = #Error# & &quot;- Missing Link URL\r&quot;>
</CFIF>

<CFIF TRIM(FORM.Description) eq &quot;&quot;>
<CFSET Error = #Error# & &quot;- Missing Link Description\r&quot;>
</CFIF>

<CFIF TRIM(FORM.Email) eq &quot;&quot;>
<CFSET Error = #Error# & &quot;- Missing Email Address\r&quot;>
</CFIF>

<CFIF len(FORM.Description) gt 75>
<CFSET Error = #Error# & &quot;- Description is too long:\r You have: #len(FORM.Description)# Allowed: 75\r&quot;>
</CFIF>


<CFIF Error neq &quot;&quot;>
<cfoutput>
<script>
// \r = return
// \t = tab
// \ before a ' or a &quot;
alert('Please Correct the following: \r\r#Error#\r');
history.go(-1);
</script>
<!-- No Script Fail over -->
<font size=&quot;2&quot; face=&quot;Verdana, Arial, Helvetica, sans-serif&quot;>
<strong>Missing Content:</strong><hr />
<CFSET error = REPLACE(ERROR,&quot;\r&quot;,&quot;<br>&quot;, &quot;ALL&quot;)>
#ERROR#
</font></cfoutput><br />
<form>
<input type=&quot;button&quot; onClick=&quot;history.go(-1);&quot; value=&quot;< Try Again&quot;>
</form>
<cfexit>
</CFIF>

<CFIF Error eq &quot;&quot;>

<cftry>
<cfquery datasource=&quot;#Request.DSN#&quot; username=&quot;#Request.DBuser#&quot; password=&quot;#Request.DBpass#&quot; dbtype=&quot;#Request.DBtype#&quot;>
INSERT INTO tb_links(
link_online,
link_updated,
link_group_id,
link_name,
link_description,
link_url,
link_email)

VALUES(
0,
#now()#,
#val(FORM.category)#,
'#trim(FORM.name)#',
'#trim(FORM.description)#',
'#trim(FORM.url)#',
'#trim(FORM.email)#'
);
</cfquery>

<cfcatch>
<CFSET NOTE = &quot;Error Inserting!! <br> Please backup and try again!&quot;>
<cflocation url=&quot;#CGI.SCRIPT_NAME#?note=#URLEncodedFormat(NOTE)#&quot; addtoken=&quot;no&quot;>
<cfexit>
</cfcatch></cftry>

<CFMAIL subject=&quot;AZ Index Link Suggestion&quot; from=&quot;webmaster&quot; to=&quot;webmaster@xxxxx.com&quot; server=&quot;xxxxxxx&quot; type=&quot;html&quot;>
<strong>Link request-</strong><br />
<CFIF TRIM(FORM.User) neq &quot;&quot;><strong>USER:</strong> #FORM.USER#<br /></CFIF>
<CFIF TRIM(FORM.email) neq &quot;&quot;><strong>EMAIL:</strong> #FORM.email#<br /></CFIF>
<CFIF TRIM(FORM.Message) neq &quot;&quot;><strong>Message:</strong> #FORM.Message#<br /></CFIF>
<strong>IP:</strong> #cgi.REMOTE_ADDR#<hr />
<strong>Link Name:</strong><br />
#FORM.NAME#<br />
<br />
<strong>Descrtion:</strong><br />
#FORM.Description#<br />
<br />
<strong>Link URL:</strong><br />
#FORM.URL#<br />
<br />
<strong>Category:</strong><br />
#FORM.category#<hr />
What do you want to do?<br />
Click here to approve and/or modify this request.<br />
<a href=&quot;#pagepath#/admin/dsp_showall.cfm&quot;>#pagepath#/admin/dsp_showall.cfm</a>
</CFMAIL>
<CFSET NOTE = &quot;Thank you for your Suggestion&quot;>
<cflocation url=&quot;#CGI.SCRIPT_NAME#?note=#URLEncodedFormat(NOTE)#&quot; addtoken=&quot;no&quot;>
<cfexit>
</CFIF>

<cfexit>
</CFIF>


<cfquery datasource=&quot;#Request.DSN#&quot; username=&quot;#Request.DBuser#&quot; password=&quot;#Request.DBpass#&quot; dbtype=&quot;#Request.DBtype#&quot; name=&quot;QRY_get_groups&quot;>
SELECT group_ID, group_NAME
FROM tb_groups
WHERE group_ONLINE = 1
</cfquery>

<?xml version=&quot;1.0&quot; encoding=&quot;iso-8859-1&quot;?>
<!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;<html xmlns=&quot;<head>
<title>A-Z Index - Suggestion</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot; />

<style type=&quot;text/css&quot;><!--
.y1{border-left:solid #4d99e5 1px;border-right:solid #4d99e5 1px;border-bottom:solid #4d99e5 1px; border-top:solid #4d99e5 1px;}
/--></style>
</head>

<body>
<cfoutput>

<br />
<CFIF URL.NOTE neq &quot;&quot;><br /><br />
<div align=&quot;center&quot;><strong><font color=&quot;RED&quot; size=&quot;4&quot; face=&quot;Arial, Helvetica, sans-serif&quot;>
#URLDECODE(URL.NOTE)#<br /></font></strong></div><br /><br /><br /><br /><br />
<cfexit>
</CFIF>

<form name=&quot;form_suggest&quot; action=&quot;#cgi.SCRIPT_NAME#&quot; method=&quot;post&quot;>
<table width=&quot;470&quot; border=&quot;0&quot; align=&quot;center&quot; cellpadding=&quot;12&quot; cellspacing=&quot;0&quot; bgcolor=&quot;white&quot;>

<tr>
<td height=&quot;270&quot; align=&quot;left&quot; valign=&quot;top&quot;><font size=&quot;3&quot; face=&quot;Verdana, Arial, Helvetica, sans-serif&quot;><strong><font size=&quot;4&quot; face=&quot;Verdana, Arial, Helvetica, sans-serif&quot;>A
- Z Index</font></strong> <br />
<font size=&quot;2&quot;>Suggest a Link Form</font><br />
<br />
</font>
<table border=&quot;0&quot; align=&quot;center&quot; cellpadding=&quot;4&quot; cellspacing=&quot;0&quot;>
<tr align=&quot;left&quot; valign=&quot;top&quot;>
<td nowrap=&quot;nowrap&quot;><strong><font size=&quot;3&quot;><font color=&quot;##CC0000&quot; size=&quot;2&quot; face=&quot;Verdana, Arial, Helvetica, sans-serif&quot;>Link
Name:</font></font></strong></td>
<td ><input name=&quot;name&quot; type=&quot;text&quot; size=&quot;50&quot;></td>
</tr>
<tr align=&quot;left&quot; valign=&quot;top&quot;>
<td nowrap=&quot;nowrap&quot;><font color=&quot;##990000&quot;><strong><font size=&quot;3&quot;><font color=&quot;##CC0000&quot; size=&quot;2&quot; face=&quot;Verdana, Arial, Helvetica, sans-serif&quot;>Link
URL:</font></font></strong></font></td>
<td ><input name=&quot;url&quot; type=&quot;text&quot; value=&quot; size=&quot;50&quot;></td>
</tr>
<tr align=&quot;left&quot; valign=&quot;top&quot;>
<td nowrap=&quot;nowrap&quot;><font size=&quot;2&quot; face=&quot;Verdana, Arial, Helvetica, sans-serif&quot;><strong><font color=&quot;##CC0000&quot;>Description:</font></strong><br />
</font></td>
<td><textarea name=&quot;description&quot; cols=&quot;38&quot; rows=&quot;3&quot;></textarea>
<br />
<font size=&quot;2&quot; face=&quot;Verdana, Arial, Helvetica, sans-serif&quot;><font size=&quot;1&quot;>*Max: 125 Characters please</font></font><br /> </td>
</tr>
<tr align=&quot;left&quot; valign=&quot;top&quot;>
<td nowrap=&quot;nowrap&quot;><strong><font color=&quot;##CC0000&quot; size=&quot;2&quot; face=&quot;Verdana, Arial, Helvetica, sans-serif&quot;>Category:</font></strong></td>
<td><table>
<tr>
<td><font size=&quot;2&quot; face=&quot;Verdana, Arial, Helvetica, sans-serif&quot;>
<label>
<input name=&quot;category&quot; type=&quot;radio&quot; value=&quot;0&quot; checked=&quot;checked&quot;/>
N/A</label>
</font></td>
</tr>
<cfloop query=&quot;QRY_get_groups&quot;>
<tr>
<td><font size=&quot;2&quot; face=&quot;Verdana, Arial, Helvetica, sans-serif&quot;>
<label>
<input type=&quot;radio&quot; name=&quot;category&quot; value=&quot;#QRY_get_groups.group_id#&quot;/>
#QRY_get_groups.group_name#</label>
</font></td>
</tr>
</cfloop>
</table></td>
</tr>
<tr align=&quot;left&quot; valign=&quot;top&quot;>
<td colspan=&quot;2&quot; nowrap=&quot;nowrap&quot;><hr size=&quot;1&quot; noshade=&quot;noshade&quot; color=&quot;990000&quot; /></td>
</tr>
<tr align=&quot;left&quot; valign=&quot;top&quot;>
<td nowrap=&quot;nowrap&quot;><font size=&quot;3&quot; face=&quot;Verdana, Arial, Helvetica, sans-serif&quot;><font color=&quot;##CC3300&quot; size=&quot;2&quot;><strong>Your
email:</strong></font></font></td>
<td><input name=&quot;email&quot; type=&quot;text&quot; id=&quot;email&quot; size=&quot;50&quot; />
</td>
</tr>
<tr align=&quot;left&quot; valign=&quot;top&quot;>
<td nowrap=&quot;nowrap&quot;><font size=&quot;3&quot; face=&quot;Verdana, Arial, Helvetica, sans-serif&quot;><font size=&quot;3&quot; face=&quot;Verdana, Arial, Helvetica, sans-serif&quot;><font size=&quot;2&quot;>Your
Name:</font></font><font color=&quot;##CC3300&quot; size=&quot;2&quot;></font></font></td>
<td><input name=&quot;User&quot; type=&quot;text&quot; id=&quot;User&quot; size=&quot;50&quot; /></td>
</tr>
<tr align=&quot;left&quot; valign=&quot;top&quot;>
<td nowrap=&quot;nowrap&quot;><font size=&quot;3&quot; face=&quot;Verdana, Arial, Helvetica, sans-serif&quot;><font size=&quot;3&quot; face=&quot;Verdana, Arial, Helvetica, sans-serif&quot;><font size=&quot;2&quot;>Message:</font></font><font color=&quot;##CC3300&quot; size=&quot;2&quot;></font></font></td>
<td><textarea name=&quot;message&quot; cols=&quot;38&quot; rows=&quot;3&quot; id=&quot;User&quot;></textarea></td>
</tr>

<tr align=&quot;left&quot; valign=&quot;top&quot;>
<td nowrap=&quot;nowrap&quot;><font size=&quot;3&quot; face=&quot;Verdana, Arial, Helvetica, sans-serif&quot;><font size=&quot;2&quot;>Your
IP:</font></font></td>
<td><font size=&quot;2&quot; face=&quot;Verdana, Arial, Helvetica, sans-serif&quot;>#cgi.REMOTE_ADDR#</font></td>
</tr>
<tr align=&quot;center&quot; valign=&quot;top&quot;>
<td colspan=&quot;2&quot; nowrap=&quot;nowrap&quot;><font color=&quot;Red&quot; size=&quot;2&quot; face=&quot;Arial, Helvetica, sans-serif&quot;><strong><br />
<font color=&quot;##CC0000&quot;>RED = Required Feilds</font></strong></font></td>
</tr>
</table>
</td>
</tr>
<tr>
<td align=&quot;center&quot; valign=&quot;top&quot;><table width=&quot;90%&quot; border=&quot;0&quot; cellpadding=&quot;1&quot; cellspacing=&quot;0&quot; bgcolor=&quot;000000&quot;>
<tr>
<td><table width=&quot;100%&quot; border=&quot;0&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot; bgcolor=&quot;whitesmoke&quot;>
<tr>
<td align=&quot;left&quot; valign=&quot;top&quot;><font size=&quot;2&quot; face=&quot;Verdana, Arial, Helvetica, sans-serif&quot;><strong>Note:</strong><br />
All requests will be reviewed in accordance with University's
Web Policies & Guidelines prior to a final posting.
Thank you.</font></td>
</tr>
</table></td>
</tr>
</table>
<br />
<input name=&quot;cmd&quot; type=&quot;hidden&quot; value=&quot;suggest&quot; />
<input type=&quot;submit&quot; value=&quot;Submit Link&quot; onClick=&quot;if(this.value == 'Submit Link') this.form.submit(); this.value = 'Please Wait...';&quot; /> </td>
</tr>
</table>

</form>

</cfoutput>
</body>
</html>


-----------------------------------------


The top is the submission...

The bottom is the form used to submit.
I must be missing something obvious but I have no clue!

Please let me know if it is my code.. or it must be an ODBC problem.

Thanks!
David McIntosh

Have a nice day!
 
Try it without the line:
<cflocation url=&quot;#CGI.SCRIPT_NAME#?note=#URLEncodedFormat(NOTE)#&quot; addtoken=&quot;no&quot;>
 
Replay... Thanks for the insight...

For aome reason the page is still processing after the cfexit.

I know this because if I put the cfabourt in its place it stopped happening.

This page was getting called from another page. And the once I added an extra If then arounf some things and a TRIM() here and there.. it fixed nicely!

Thanks again for the help! You got it right on. David McIntosh

Have a nice day!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top