• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Multiple URL variables and cfMail

Explorer ,
Nov 30, 2012 Nov 30, 2012

Copy link to clipboard

Copied

Hi,

I posted this on the bottom of a different discussion I posted (Passing two URL variables) where my problem was solved.  But now that I know how to pass two URL variables, I'm having trouble putting one of those variables to use.

I'm working on a page like this:

     http://mymindsnotright.com/discussionGenReplies.cfm?post_id=22

and i'm trying to set it up so, when I click a 'post reply' link, an email is sent to the original poster and the person whose reply you clicked 'post reply' on.  The idea was to use URL variables, so (as you  can see on the page i linked above) when I click a post reply link, the user_id of the person who posted the reply that i'm replying to shows up in the URL like this:

     http://mymindsnotright.com/discussionGenReplies.cfm?post_id=22&user_id =4#replytest

but for some reason the user_id in the URL isn't being used and instead it's just using the information from the first row in the table--even though the correct user_id is being shown in the URL

Here's what I'm working with:

====================================================================

<cfparam name="URL.post_id" default="1">

<cfset CurrentPage=GetFileFromPath(GetBaseTemplatePath())>

<cfparam name="URL.user_id" default="1">

<cfparam name="FORM.post_id" default="1">

<cfquery name="rsGenPost" datasource="mymindsnotrighttest" username="mikewycklendt" password="Mex0Wix0">

SELECT *

FROM boardtopics

WHERE post_id = <cfqueryparam value="#URL.post_id#" cfsqltype="cf_sql_numeric">

</cfquery>

<cfquery name="rsTopicInfoForEmail" datasource="mymindsnotrighttest" username="mikewycklendt" password="Mex0Wix0">

SELECT *

FROM boardtopics

WHERE post_id = <cfqueryparam value="#FORM.post_id#" cfsqltype="cf_sql_numeric">

</cfquery>

<cfquery name="rsReplyToReplyEmail" datasource="mymindsnotrighttest" username="mikewycklendt" password="Mex0Wix0">

SELECT *

FROM user_accounts

WHERE user_id = <cfqueryparam value="#URL.user_id#" cfsqltype="cf_sql_numeric">

</cfquery>

<cfif IsDefined("FORM.MM_InsertRecord") AND FORM.MM_InsertRecord EQ "form1">

  <cfquery datasource="mymindsnotrighttest" password="Mex0Wix0" username="mikewycklendt">

  INSERT INTO board_replies (reply_id, post_id, board_id, user_id, username, title, content, date)

VALUES (<cfif IsDefined("FORM.reply_id") AND #FORM.reply_id# NEQ "">

<cfqueryparam value="#FORM.reply_id#" cfsqltype="cf_sql_numeric">

<cfelse>

NULL

</cfif>

, <cfif IsDefined("FORM.post_id") AND #FORM.post_id# NEQ "">

<cfqueryparam value="#FORM.post_id#" cfsqltype="cf_sql_numeric">

<cfelse>

NULL

</cfif>

, <cfif IsDefined("FORM.board_id") AND #FORM.board_id# NEQ "">

<cfqueryparam value="#FORM.board_id#" cfsqltype="cf_sql_numeric">

<cfelse>

NULL

</cfif>

, <cfif IsDefined("FORM.user_id") AND #FORM.user_id# NEQ "">

<cfqueryparam value="#FORM.user_id#" cfsqltype="cf_sql_numeric">

<cfelse>

NULL

</cfif>

, <cfif IsDefined("FORM.username") AND #FORM.username# NEQ "">

<cfqueryparam value="#FORM.username#" cfsqltype="cf_sql_clob" maxlength="65535">

<cfelse>

''

</cfif>

, <cfif IsDefined("FORM.title") AND #FORM.title# NEQ "">

<cfqueryparam value="#FORM.title#" cfsqltype="cf_sql_clob" maxlength="65535">

<cfelse>

''

</cfif>

, <cfif IsDefined("FORM.content") AND #FORM.content# NEQ "">

<cfqueryparam value="#FORM.content#" cfsqltype="cf_sql_clob" maxlength="2147483647">

<cfelse>

''

</cfif>

, <cfif IsDefined("FORM.date") AND #FORM.date# NEQ "">

<cfqueryparam value="#FORM.date#" cfsqltype="cf_sql_timestamp">

<cfelse>

NULL

</cfif>

)

<cfquery name="rsEmail" datasource="mymindsnotrighttest" username="mikewycklendt" password="Mex0Wix0">

SELECT *

FROM user_accounts

WHERE user_id = <cfoutput>#rsTopicInfoForEmail.user_id#</cfoutput>

</cfquery>

<cfquery name="rsEmailtoReply" datasource="mymindsnotrighttest" username="mikewycklendt" password="Mex0Wix0">

SELECT *

FROM user_accounts

WHERE user_id = <cfoutput>#rsReplyToReplyEmail.user_id#</cfoutput>

</cfquery>

<cfmail

        TO="mikewycklendt@gmail.com"

        from="mikewycklendt@mymindsnotright.com"

        subject="#FORM.username#"

        server="scriptmail.intermedia.net"

        >#FORM.username# has replied to your post (#rsTopicInfoForEmail.title#)

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

You can see the reply by clicking this link:

http://www.mymindsnotright.com/discussionGenReplies.cfm?post_id=#FORM. post_id#

should send to:  #rsEmail.user_email#

and a reply to #rsEmailToReply.username# reply who has the email:

#rsEmailToReply.user_email#

  </cfmail>

  </cfquery>

  <cflocation url="discussionGenReplies.cfm?post_id=#FORM.post_id#">

</cfif>

<cfquery name="rsGenReplies" datasource="mymindsnotrighttest" username="mikewycklendt" password="Mex0Wix0">

SELECT *

FROM board_replies

WHERE post_id = <cfqueryparam value="#URL.post_id#" cfsqltype="cf_sql_numeric">

ORDER BY reply_id ASC

</cfquery>

<cfquery name="rsReplyRecordCount" datasource="mymindsnotrighttest" username="mikewycklendt" password="Mex0Wix0">

SELECT *

FROM board_replies

</cfquery>

Views

3.0K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 30, 2012 Nov 30, 2012

Copy link to clipboard

Copied

I glanced through the code but let's focus on this statement:  "but for some reason the user_id in the URL isn't being used and instead it's just using the information from the first row in the table--even though the correct user_id is being shown in the URL"

When you get data from a query object without specifying the row number, you get data from the first row.  That is probably what is happening to you.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 01, 2012 Dec 01, 2012

Copy link to clipboard

Copied

Thanks for the reply,

Yeah, but I'm specifying the row to use in the user_accounts table in the URL... when I click "Post Reply" on one of the replies, it takes me down the page to the form (by using a named anchor) and the correct user_id shows in the URL like this:

http://mymindsnotright.com/discussionGenReplies.cfm?post_id=22&user_id =4#replytest

so the correct user_id shows up in the URL, but when I try to use it in the code I posted above, I'm only getting the information from the first row when, in this example, the information should be coming from the fourth row.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 01, 2012 Dec 01, 2012

Copy link to clipboard

Copied

Remove the line <cfparam name="URL.user_id" default="1"> and see if it helps. I say this because it looks like your link has a space just after user_id.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 01, 2012 Dec 01, 2012

Copy link to clipboard

Copied

Thanks for the reply,

I checked on the space and it's not the issue.  I'd already tried taking out that line of code but the page won't load and i get the error

Element USER_ID is undefined in URL.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 01, 2012 Dec 01, 2012

Copy link to clipboard

Copied

I was guessing that the variable url.user_id was the one coming from the cfparam tag, and not the one from the URL. The error message confirms this. In your code, there is a space where I have put *. It just might be the cause of the error. Remove the space, save the file and try again.

http://mymindsnotright.com/discussionGenReplies.cfm?post_id=22&user_id*=4#replytest

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 01, 2012 Dec 01, 2012

Copy link to clipboard

Copied

for some reason that space is only on the link i posted here... i looked at the code and that link's page as well and there is no space to take out.

if you click the link yourself, you'll see there is no space

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 02, 2012 Dec 02, 2012

Copy link to clipboard

Copied

OK, that rules that out. For the next test, change the cfparam line to <cfparam name="URL.user_id" default="5">. Add the line <cfdump var="#url#"> just before the query rsReplyToReplyEmail. Repeat the calls or open the pages in the usual order. That is, with the value user_id=4 in the query-string. Which URL variables are dumped?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 02, 2012 Dec 02, 2012

Copy link to clipboard

Copied

Thanks for the reply.

When the page loads, the cfdump returns "5" for the user_id.  When I click 'post reply' under a reply, it goes down to the page to the form (named anchor) and if i scroll up back up, the user_id the cfdump returns has changed to the correct value for user_id (using the url variable).  When I scroll back down and submit the form and the page reloads, the cfdump returns "5" again for the user_id.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 02, 2012 Dec 02, 2012

Copy link to clipboard

Copied

That clearly says that you are not arriving at the page by the URL you think you are. That is, you are not arriving at the page by http://mymindsnotright.com/discussionGenReplies.cfm?post_id=22&user_id=4#replytest .

I would now hazard another guess. You should add appropriate URL variables to the action in the line:

<form method="post" name="form1" action="#currentTemplateRelativePath#">

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 02, 2012 Dec 02, 2012

Copy link to clipboard

Copied

Thanks for the reply,

I guess I wasn't clear--yeah, when the page loads it looks like this:

     http://mymindsnotright.com/discussionGenReplies.cfm?post_id=22

and then when I click 'post reply' it goes further down on the page to the form using a named anchor and the URL then looks like th is:

     http://mymindsnotright.com/discussionGenReplies.cfm?post_id=22&user_id=4#replytest

When I made the change you suggested, i get the error:

Variable CURRENTTEMPLATERELATIVEPATH is undefined.

Another thing I forgot to mention is that the form is an include, and this is the code for it:

======================================================================

<cfif isDefined("FORM.title")>

<cfdump var="#form#">

<span class="blogtitle">Your Email has been sent.<br><br>I'll get back to you as soon as I can.</span>

<cfelse>

    <cfform method="post" name="form1" action="#currentTemplateRelativePath#">

    <table align="center" cellpadding="4">

    <tr valign="baseline">

    <td colspan="2" align="left" nowrap bgcolor="#FFFFFF" class="blogtitle"> </td>

    </tr>

    <tr valign="baseline">

    <td align="right" nowrap class="bloguserandwho"> </td>

    <td><cfinput type="hidden" name="user_id" value="#rsGetUserID.user_id#" size="32"></td>

    </tr>

    <tr valign="baseline">

    <td align="right" nowrap class="bloguserandwho">Username:</td>

    <td><cfinput type="hidden" name="username" id="username" value="#Session.MM_Username#" size="32" />                          <cfoutput>#Session.MM_Username#</cfoutput>

    </td>

    </tr>

    <tr valign="baseline">

    <td align="right" nowrap class="bloguserandwho">Title:</td>

    <td><cfinput type="text" name="title" id="title" size="32"></td>

    </tr>

    <tr valign="baseline">

    <td align="right" valign="top" nowrap class="bloguserandwho">Content:</td>

    <td><textarea name="content"  id="content" cols="30" rows="5"></textarea></td>

    </tr>

    <tr valign="baseline">

    <td nowrap align="right"> </td>

    <td><cfinput name="submit" type="submit" value="Post Reply"></td>

    </tr>

    </table>

    <cfinput type="hidden" name="reply_id" value="#IncrementValue(rsReplyRecordCount.RecordCount)#">

    <cfinput type="hidden" name="post_id" value="#URL.post_id#">

    <cfinput type="hidden" name="board_id" value="1">

    <cfinput type="hidden" name="date" value="#now()#">

    <cfinput type="hidden" name="MM_InsertRecord" value="form1">

    </cfform>

</cfif>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 02, 2012 Dec 02, 2012

Copy link to clipboard

Copied

wycks wrote:

When I made the change you suggested, i get the error:

Variable CURRENTTEMPLATERELATIVEPATH is undefined.

My apologies. I just copied the first form tag at hand. The variable currenttemplaterelativepath was a suggestion of my own. We have moved on since then.

I believe you now use <form method="post" name="form1" action="#CGI.SCRIPT_NAME#">. So, add the appropriate URL variables to that.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 02, 2012 Dec 02, 2012

Copy link to clipboard

Copied

what exactly do you mean bv "addinig the appropriate variables to that"

like this?

<cfform method="post" name="form1" action="#CGI.SCRIPT_NAME#?post_id=#rsGenReplies.post_id#&user_id=#rsGenReplies.user_id#">

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 02, 2012 Dec 02, 2012

Copy link to clipboard

Copied

yes.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 03, 2012 Dec 03, 2012

Copy link to clipboard

Copied

Thanks a lot for the reply and all the help, but I'm still having issues.

I changed the form1 action to this:

         <cfform method="post" name="form1" action="#CGI.SCRIPT_NAME#?post_id=#rsGenReplies.post_id#&user_id=#rsReplyToReplyEmail.user_id#">

I also tried this:

         <cfform method="post" name="form1" action="#CGI.SCRIPT_NAME#?post_id=#rsGenReplies.post_id#&user_id=#rsURL.user_id#">

and the cf dump still sticks with the user_id variable defined near the top of the page.

Also, after submitting the form, this is the URL that returns:

     http://localhost:8500/Htdocs/discussionGenReplies.cfm?post_id=10&CFID=4900&CFTOKEN=36760993

shouldn't there be a user)id variable in that URL after submitting the form with the new form1 action?

This is a chunk of the code I'm working with for discussionGenReplies.cfm

==============================================================================

<cfparam name="URL.post_id" default="1">

<cfset CurrentPage=GetFileFromPath(GetBaseTemplatePath())>

<cfparam name="URL.user_id" default="11">

<cfparam name="FORM.post_id" default="1">

<cfquery name="rsGenPost" datasource="mymindsnotrighttest" username="mikewycklendt" password="Mex0Wix0">

SELECT *

FROM boardtopics

WHERE post_id = <cfqueryparam value="#URL.post_id#" cfsqltype="cf_sql_numeric">

</cfquery>

<cfquery name="rsTopicInfoForEmail" datasource="mymindsnotrighttest" username="mikewycklendt" password="Mex0Wix0">

SELECT *

FROM boardtopics

WHERE post_id = <cfqueryparam value="#FORM.post_id#" cfsqltype="cf_sql_numeric">

</cfquery>

<cfdump var="#url#">

<cfquery name="rsReplyToReplyEmail" datasource="mymindsnotrighttest" username="mikewycklendt" password="Mex0Wix0">

SELECT *

FROM user_accounts

WHERE user_id = <cfqueryparam value="#URL.user_id#" cfsqltype="cf_sql_numeric">

</cfquery>

<cfif IsDefined("FORM.MM_InsertRecord") AND FORM.MM_InsertRecord EQ "form1">

  <cfquery datasource="mymindsnotrighttest" password="Mex0Wix0" username="mikewycklendt">

  INSERT INTO board_replies (reply_id, post_id, board_id, user_id, username, title, content, date)

VALUES (<cfif IsDefined("FORM.reply_id") AND #FORM.reply_id# NEQ "">

<cfqueryparam value="#FORM.reply_id#" cfsqltype="cf_sql_numeric">

<cfelse>

NULL

</cfif>

, <cfif IsDefined("FORM.post_id") AND #FORM.post_id# NEQ "">

<cfqueryparam value="#FORM.post_id#" cfsqltype="cf_sql_numeric">

<cfelse>

NULL

</cfif>

, <cfif IsDefined("FORM.board_id") AND #FORM.board_id# NEQ "">

<cfqueryparam value="#FORM.board_id#" cfsqltype="cf_sql_numeric">

<cfelse>

NULL

</cfif>

, <cfif IsDefined("FORM.user_id") AND #FORM.user_id# NEQ "">

<cfqueryparam value="#FORM.user_id#" cfsqltype="cf_sql_numeric">

<cfelse>

NULL

</cfif>

, <cfif IsDefined("FORM.username") AND #FORM.username# NEQ "">

<cfqueryparam value="#FORM.username#" cfsqltype="cf_sql_clob" maxlength="65535">

<cfelse>

''

</cfif>

, <cfif IsDefined("FORM.title") AND #FORM.title# NEQ "">

<cfqueryparam value="#FORM.title#" cfsqltype="cf_sql_clob" maxlength="65535">

<cfelse>

''

</cfif>

, <cfif IsDefined("FORM.content") AND #FORM.content# NEQ "">

<cfqueryparam value="#FORM.content#" cfsqltype="cf_sql_clob" maxlength="2147483647">

<cfelse>

''

</cfif>

, <cfif IsDefined("FORM.date") AND #FORM.date# NEQ "">

<cfqueryparam value="#FORM.date#" cfsqltype="cf_sql_timestamp">

<cfelse>

NULL

</cfif>

)

<cfquery name="rsEmail" datasource="mymindsnotrighttest" username="mikewycklendt" password="Mex0Wix0">

SELECT *

FROM user_accounts

WHERE user_id = <cfoutput>#rsTopicInfoForEmail.user_id#</cfoutput>

</cfquery>

<cfquery name="rsEmailtoReply" datasource="mymindsnotrighttest" username="mikewycklendt" password="Mex0Wix0">

SELECT *

FROM user_accounts

WHERE user_id = <cfoutput>#rsReplyToReplyEmail.user_id#</cfoutput>

</cfquery>

<cfmail

        TO="mikewycklendt@gmail.com"

        from="mikewycklendt@mymindsnotright.com"

        subject="#FORM.username#"

        server="scriptmail.intermedia.net" 

        >#FORM.username# has replied to your post (#rsTopicInfoForEmail.title#)

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

You can see the reply by clicking this link:

http://www.mymindsnotright.com/discussionGenReplies.cfm?post_id=#FORM.post_id#

should send to:  #rsEmail.user_email#

and a reply to #rsEmailToReply.username# reply who has the email:

#rsEmailToReply.user_email#

  </cfmail>

  </cfquery>

  <cflocation url="discussionGenReplies.cfm?post_id=#FORM.post_id#">

</cfif>

<cfquery name="rsGenReplies" datasource="mymindsnotrighttest" username="mikewycklendt" password="Mex0Wix0">

SELECT *

FROM board_replies

WHERE post_id = <cfqueryparam value="#URL.post_id#" cfsqltype="cf_sql_numeric">

ORDER BY reply_id ASC

</cfquery>

<cfquery name="rsReplyRecordCount" datasource="mymindsnotrighttest" username="mikewycklendt" password="Mex0Wix0">

SELECT *

FROM board_replies

</cfquery>

==============================================================================

and this is the code for the form (which is used as an include in discussionGenReplies.cfm):

==============================================================================

\

<cfif isDefined("FORM.title")>

<cfdump var="#form#">

<span class="blogtitle">Your Email has been sent.<br><br>I'll get back to you as soon as I can.</span>

<cfelse>

    <cfform method="post" name="form1" action="#CGI.SCRIPT_NAME#?post_id=#rsGenReplies.post_id#&user_id=#rsReplyToReplyEmail.user_id#">

    <table align="center" cellpadding="4">

    <tr valign="baseline">

    <td colspan="2" align="left" nowrap bgcolor="#FFFFFF" class="blogtitle"> </td>

    </tr>

    <tr valign="baseline">

    <td align="right" nowrap class="bloguserandwho"> </td>

    <td><cfinput type="hidden" name="user_id" value="#rsGetUserID.user_id#" size="32"></td>

    </tr>

    <tr valign="baseline">

    <td align="right" nowrap class="bloguserandwho">Username:</td>

    <td><cfinput type="hidden" name="username" id="username" value="#Session.MM_Username#" size="32" />                          <cfoutput>#Session.MM_Username#</cfoutput>

    </td>

    </tr>

    <tr valign="baseline">

    <td align="right" nowrap class="bloguserandwho">Title:</td>

    <td><cfinput type="text" name="title" id="title" size="32"></td>

    </tr>

    <tr valign="baseline">

    <td align="right" valign="top" nowrap class="bloguserandwho">Content:</td>

    <td><textarea name="content"  id="content" cols="30" rows="5"></textarea></td>

    </tr>

    <tr valign="baseline">

    <td nowrap align="right"> </td>

    <td><cfinput name="submit" type="submit" value="Post Reply"></td>

    </tr>

    </table>

    <cfinput type="hidden" name="reply_id" value="#IncrementValue(rsReplyRecordCount.RecordCount)#">

    <cfinput type="hidden" name="post_id" value="#URL.post_id#">

    <cfinput type="hidden" name="board_id" value="1">

    <cfinput type="hidden" name="date" value="#now()#">

    <cfinput type="hidden" name="MM_InsertRecord" value="form1">

    </cfform>

</cfif>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 03, 2012 Dec 03, 2012

Copy link to clipboard

Copied

     http://localhost:8500/Htdocs/discussionGenReplies.cfm?post_id=10&CFID= 4900&CFTOKEN=36760993

The main problem is, there are too many factors changing at the same time. Now there are CFID and CFToken in the URL. This raises the question how you have set up your application.

You should not append session tokens to the URL. Instead, use in your application file, settings like the following:

applicationTimeout = "#createTimespan(1,0,0,0)#"

sessionmanagement = "true"

sessionTimeout = "#createTimespan(0,0,20,0)#"

setClientCookies = "true"

I changed the form1 action to this:

         <cfform method="post" name="form1" action="#CGI.SCRIPT_NAME#?post_id=#rsGenReplies.post_id#&user_id=#rsR eplyToReplyEmail.user_id#">

I also tried this:

         <cfform method="post" name="form1" action="#CGI.SCRIPT_NAME#?post_id=#rsGenReplies.post_id#&user_id=#rsU RL.user_id#">

and the cf dump still sticks with the user_id variable defined near the top of the page.

Also, after submitting the form, this is the URL that returns:

     http://localhost:8500/Htdocs/discussionGenReplies.cfm?post_id=10&CFID= 4900&CFTOKEN=36760993

shouldn't there be a user)id variable in that URL after submitting the form with the new form1 action?

Indeed, user_id should appear in the URL when you submit the form <cfform method="post" name="form1" action="#CGI.SCRIPT_NAME#?post_id=#rsGenReplies.post_id#&user_id=#rsURL.user_id#">. To debug this, place the following line just before the form tag:

<p>Action: <cfoutput>#CGI.SCRIPT_NAME#?post_id=#rsGenReplies.post_id#&user_id=#rsURL.user_id#</cfoutput></p>

What is the output?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 03, 2012 Dec 03, 2012

Copy link to clipboard

Copied

when i first load the page, i see this:

     Action: /Htdocs/discussionGenReplies.cfm?post_id=10&user_id=

          and the cfdump for user_id shows 11 (set by <cfparam name="URL.user_id" default="11"> at the top of the page 'discussionGenReplies.cfm

when I click one of the 'post reply' links, I see this:

     Action: /Htdocs/discussionGenReplies.cfm?post_id=10&user_id=3

          -that is the correct user_id and the cfdump at the top of the page also gives me the right user_id (3)

then when I submit the form, I see this (again)

     Action: /Htdocs/discussionGenReplies.cfm?post_id=10&user_id=

          and the cfdump for user_id is 11 again

               and the URL shows: http://localhost:8500/Htdocs/discussionGenReplies.cfm?post_id=10&CFID=4900&CFTOKEN=36760993

and i'm working with this:

<p>Action: <cfoutput>#CGI.SCRIPT_NAME#?post_id=#rsGenReplies.post_id#&user_id=#rsReplyToReplyEmail.user_id#</cfoutput></p>

    <cfform method="post" name="form1" action="#CGI.SCRIPT_NAME#?post_id=#rsGenReplies.post_id#&user_id=#rsReplyToReplyEmail.user_id#">


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 03, 2012 Dec 03, 2012

Copy link to clipboard

Copied

LATEST
Action: /Htdocs/discussionGenReplies.cfm?post_id=10&user_id=

Precisely what I was after. That tells me there is no value for rsReplyToReplyEmail.user_id. Verify the query rsReplyToReplyEmail and the data.

My gut feeling is that something is missing from the setting of user_id. I have walked through the page. When the page opens initially, cfparam sets the default value. This value is the basis for the query rsReplyToReplyEmail. Presumably, the query supplies a new value for the user_id, namely,  rsReplyToReplyEmail.user_id. Is this user_id different from the one in the where-clause of the query?

If they are the same, then there is duplication in the code. That will have to be fixed. If they are different, then there is inconsistency in the code. That will also have to be fixed.

Now that rsReplyToReplyEmail.user_id has entered the food chain, it reappears as the URL variable, user_id,  in the action of the form. That value is recycled back to the main page when the form is submitted. It then goes back to being the user_id in the where-clause of the query rsReplyToReplyEmail. That is a cycle that keeps rotating the same value of user_id.

You have to break it by introducing the real user_id. At some point this user ID has to replace the default ID set by cfparam. I remember suggesting some days ago that you use, for example, getAuthUser() to identify the actual user. You could then use the username in the where-clause of the query.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation