Copy link to clipboard
Copied
(I first posted this on the dynamic dreamweaver forum but I think I was supposed to post my question here)
Hi,
I'm trying to figure out a way to notify someone that another person has replied to a post they made in a discussion. I'm pretty sure I know how to figure out who the email should be sent to, but for now I'm just trying to get it to work by just sending it to my personal email. This is the code I'm trying to get to work:
Thanks,
Mike
======================================================================
<cfif isDefined("FORM.title")>
<cfprocessingdirective suppresswhitespace="No">
<span class="blogtitle">Your Email has been sent.<br><br>I'll get back to you as soon as I can.
</span>
<cfmail
from="""#FORM.username#"" <mikewycklendt@mymindsnotright.com>"
subject="#FORM.title#"
server="scriptmail.intermedia.net"
>This is a message from #FORM.username#:
Email: #FORM.username#
-------------------------------------------------
#FORM.content#
</cfmail>
</cfprocessingdirective>
<cfelse>
<form method="post" name="form1" action="<cfoutput>#CurrentPage#</cfoutput>">
<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><input type="hidden" name="user_id" value="<cfoutput>#rsGetUserID.user_id#</cfoutput>" size="32"></td>
</tr>
<tr valign="baseline">
<td align="right" nowrap class="bloguserandwho">Username:</td>
<td><input type="hidden" name="username" id="username" value="<cfoutput>#Session.MM_Username#</cfoutput>" size="32" /> <cfoutput>#Session.MM_Username#</cfoutput>
</td>
</tr>
<tr valign="baseline">
<td align="right" nowrap class="bloguserandwho">Title:</td>
<td><input type="text" name="title" id="title" value="" 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><input type="submit" value="Post Reply"></td>
</tr>
</table>
<input type="hidden" name="reply_id" value="<cfoutput>#IncrementValue(rsReplyRecordCount.RecordCount)#</cf output>">
<input type="hidden" name="post_id" value="<cfoutput>#URL.post_id#</cfoutput>">
<input type="hidden" name="board_id" value="1">
<input type="hidden" name="date" value="<cfoutput>#now()#</cfoutput>">
<input type="hidden" name="MM_InsertRecord" value="form1">
</form>
</cfif>
Copy link to clipboard
Copied
Could you tell us what the problem is.
Copy link to clipboard
Copied
Oh yeah, I guess I didn't. I know that the cfmail won't work on localhost but I uploaded it to my site to test it. The form itself works (it posts a reply to a topic) but no email is sent.
Copy link to clipboard
Copied
Comment out the rest of the code and run just this test code:
Your Email has been sent.<br>
I'll get back to you as soon as I can.<br>
<cfmail
from="mikewycklendt@mymindsnotright.com"
subject="Test title"
server="scriptmail.intermedia.net">
E-mail message sent as test.
</cfmail>
Copy link to clipboard
Copied
the form posts it's reply, but still does not send an email. I have another page on my website that uses cfmail and that one does work.
Copy link to clipboard
Copied
and this part:
Your Email has been sent.<br>
I'll get back to you as soon as I can.<br>
Does not show after submitting the form.
Copy link to clipboard
Copied
The code I posted is being used as an include on this larger page:
=====================================================================
<cfparam name="URL.post_id" default="1">
<cfset CurrentPage=GetFileFromPath(GetBaseTemplatePath())>
<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>
<cflocation url="discussionGenReplies.cfm?post_id=#FORM.post_id#">
</cfif>
<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="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>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>My Minds Not Right -- General Discussion : <cfoutput>#rsGenPost.title#</cfoutput></title>
<link rel="stylesheet" type="text/css" href="HTML/style.css">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
.blogcontent {
font-size: 11pt;
font-family: Tahoma, Geneva, sans-serif;
}
.comments {
font-family: Tahoma, Geneva, sans-serif;
font-size: 12px;
font-weight: bold;
text-decoration: underline;
text-align: right;
color: #246494;
}
.FeaturedBlogList {
font-family: Tahoma, Geneva, sans-serif;
font-size: 11px;
}
.FeaturedBlogListHeader {
font-family: Tahoma, Geneva, sans-serif;
font-size: 12px;
font-weight: bold;
color: #246494;
/* [disabled]border-bottom-style: solid; */
}
.blogdate {
font-size: 9pt;
font-style: italic;
font-family: Tahoma, Geneva, sans-serif;
}
.bloguserandwho {
font-size: 10pt;
font-style: normal;
font-family: Tahoma, Geneva, sans-serif;
}
.redlink {
font-family: Tahoma, Geneva, sans-serif;
color: #F00;
font-size: 10pt;
}
.blogtitle {
font-size: 16px;
font-weight: bold;
font-family: Tahoma, Geneva, sans-serif;
color: #246494;
}
.quoteStyle {
font-family: Verdana, Geneva, sans-serif;
font-size: 11pt;
font-style: italic;
color: #000;
}
.justified {
text-align: justify;
}
</style>
<script type="text/javascript">
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a)&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a.indexOf("#")!=0){ d.MM_p
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers.document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
</script>
</head>
<body bgcolor="#ffffff" leftmargin=0 topmargin=0 marginwidth="0" marginheight="0" onLoad="MM_preloadImages('images/about_invert.jpg','images/discussion_invert.jpg','images/family_invert.jpg','images/askquestion_invert.jpg','images/newsletters_invert.jpg','images/home_invert.jpg')">
<table border="0" cellspacing="0" cellpadding="0" width="100%" height="100%">
<tr>
<td width="50%" background="images/bg.gif" valign="top"><img src="images/px1.gif" width="1" height="1" alt="" border="0"></td>
<td valign="top" background="images/bg_left.gif"><img src="images/bg_left.gif" alt="" width="17" height="16" border="0">
</td>
<td valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="780"></td>
<td width="100%">
<table width="780" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="images/logo01new.jpg" width="510" height="126"><img src="images/logo02clean.jpg" width="270" height="126" border="0"></td>
</tr>
<tr>
<cfinclude template="topBar.cfm">
</tr>
</table>
</td>
</tr>
</table>
<cfinclude template="sideBar.cfm">
<p class="left"><cfinclude template="includes/sidebarLinks.cfm">
<br>
</p>
<!-- /left -->
</td>
<td rowspan="2" width="100%">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>
<td background="images/fon_right.gif"><img src="images/BARS/GENERALDISCUSSIONTOPIC.jpg" width="323" height="35" alt="" border="0"></td>
<td bgcolor="#B9B9B9"><img src="images/px1.gif" width="1" height="1" alt="" border="0"></td>
<td background="images/fon_right.gif"> </td>
<td bgcolor="#B9B9B9"><img src="images/px1.gif" width="1" height="1" alt="" border="0"></td>
<td valign="top" rowspan="2" width="100%">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="2"><img src="images/2_f_2.gif" width="2" height="35"></td>
<td background="images/2_f_2_fon.gif" width="100%"><img src="images/topend.jpg" width="28" height="36"></td>
</tr>
</table></td>
</tr>
<tr valign="top">
<td background="images/fon01.gif" style="background-position: top; background-repeat: repeat-x; font-size: 9px; font-family: Tahoma, Geneva, sans-serif; color: #000;"><table border="0" cellspacing="0" cellpadding="0" width="90%" background="" align="center">
<tr valign="top">
<td align="left"><h6> </h6>
<table width="95%" border="0">
<tr>
<td width="66%" align="left" class="FeaturedBlogListHeader">posted by: <span class="redlink"><a href="userProfile.cfm?user_id=<cfoutput>#rsGenPost.user_id#</cfoutput>"><cfoutput>#rsGenPost.username#</cfoutput></a><br>
</span><cfoutput>#LSDateFormat(rsGenPost.date,'M/DD/YY')#</cfoutput><span class="redlink"><cfoutput><span class="blogdate"></span></cfoutput></span></td>
<td width="34%" align="right"><span class="blogtitle"><a href="discussionGeneral.cfm?board_id=1">General Discussion</a></span></td>
</tr>
<tr>
<td colspan="2"><hr class="blogtitle"></td>
</tr>
<tr>
<td colspan="2"><cfoutput>
<p class="blogtitle">#rsGenPost.title#</p>
</cfoutput></td>
</tr>
<tr>
<td colspan="2" align="right"><cfoutput></cfoutput></td>
</tr>
<tr>
<td colspan="2"><cfoutput>#ParagraphFormat(rsGenPost.content)#</cfoutput></td>
</tr>
<tr>
<td colspan="2"><hr class="blogtitle"></td>
</tr>
<tr>
<td colspan="2" align="right"><a href="#replytest" class="redlink"><strong>Post Reply</strong></a></td>
</tr>
</table>
<p class="blogtitle"> </p>
<table width="95%" border="0">
<tr>
<td align="right" class="blogtitle">Replies (<cfoutput>#rsGenReplies.RecordCount#</cfoutput>)</td>
</tr>
</table>
<br>
<cfoutput query="rsGenReplies">
<table width="95%" border="0" cellpadding="4" cellspacing="0">
<tr>
<td width="78%" bgcolor="##DADADA"><strong><span class="blogcontent">#rsGenReplies.title#</span></strong></td>
<td width="22%" align="right" bgcolor="##DADADA"><span class="FeaturedBlogListHeader"><a href="userProfile.cfm?user_id=#rsGenPost.user_id#">#rsGenReplies.username#</a></span></td>
</tr>
<tr>
<td colspan="2" align="right"><span class="blogdate">#LSDateFormat(rsGenReplies.date,'M/DD/YY')#</span></td>
</tr>
<tr>
<td colspan="2" align="right"></td>
</tr>
<tr>
<td colspan="2" class="bloguserandwho">#ParagraphFormat(rsGenReplies.content)#</td>
</tr>
<tr>
<td colspan="2" align="right"><a href="##replytest" class="redlink"><strong><span class="bloguserandwho"></span></strong></a><a href="##replytest" class="redlink"><strong>Post Reply</strong></a></td>
</tr>
<tr>
<td colspan="2" align="right"> </td>
</tr>
</table>
</cfoutput>
<p class="bloguserandwho"> </p>
<p class="bloguserandwho"> </p>
<p class="bloguserandwho"> </p>
<p class="blogtitle"> </p></td>
</tr>
</table>
</td>
<td bgcolor="#B9B9B9"><img src="images/px1.gif" width="1" height="1" alt="" border="0"></td>
<td background="images/fon01.gif" style="background-position: top; background-repeat: repeat-x;">
<br></td>
<td bgcolor="#B9B9B9"><img src="images/px1.gif" width="1" height="1" alt="" border="0"></td>
</tr>
<tr>
<td background="images/fon02.gif" colspan="3"><img src="images/BARS/POSTNEWREPLY.jpg" width="563" height="43" alt="" border="0"></td>
<td bgcolor="#B9B9B9"><img src="images/px1.gif" width="1" height="1" alt="" border="0"></td>
<td background="images/fon_right.gif" width="100%"><img src="images/px1.gif" width="1" height="1" alt="" border="0"></td>
</tr>
<tr>
<td colspan="3" align="left" valign="top"><blockquote>
<a name="replytest" id="replytest"></a>
<cfinclude template="discussionGenRepliesFORMinclude.cfm">
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
</blockquote>
<p> </p>
<p> </p>
<p> </p>
<p> </p></td>
<td bgcolor="#B9B9B9"><img src="images/px1.gif" width="1" height="1" alt="" border="0"></td>
<td>
<div align="left"><img src="images/px1.gif" width="1" height="1" alt="" border="0"></div>
</td>
</tr>
</table>
</td>
</tr>
<tr bgcolor="#246494">
<td valign="bottom">
<table border="0" cellspacing="0" cellpadding="0" width="188" height="67" background="images/left_bot.gif">
<tr>
<td valign="bottom">
<p class="left" style="margin-bottom: 0px; margin-left: 20px;">Copyright
©2010<br>
MyMindsNotRight.com<br>
All rights reserved</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
<table border="0" cellspacing="0" cellpadding="0" width="100%" height="77" background="images/fon_bot.gif">
<tr>
<td valign="top" width="780">
<cfinclude template="bottomBar.cfm">
</td>
<td><img src="images/px1.gif" width="1" height="1" alt="" border="0"></td>
</tr>
<tr>
<td><img src="images/px1.gif" width="780" height="1" alt="" border="0"></td>
<td><img src="images/px1.gif" width="1" height="1" alt="" border="0"></td>
</tr>
</table>
</td>
<td valign="bottom" background="images/bg_right.gif"><img src="images/bg_right.gif" alt="" width="17" height="16" border="0"></td>
<td width="50%" background="images/bg.gif" valign="top"><img src="images/px1.gif" width="1" height="1" alt="" border="0"></td>
</tr>
</table>
</body>
</html>
Copy link to clipboard
Copied
It is easier to test 2 lines of code than 5 miles of it. Notice that the test I suggested, by not using form variables, actually verifies whether they are the cause of the problem.
In any case, one thing in particular caught my eye. The attribute
from="""#FORM.username#"" <mikewycklendt@mymindsnotright.com>"
What happens when you replace it with either
from="mikewycklendt@mymindsnotright.com"
or
from="#FORM.username#"
(I am assuming here that FORM.username is an e-mail address)
Copy link to clipboard
Copied
form still posts the reply but nothing comes to my email
Copy link to clipboard
Copied
on the page i have where the cfmail does work, I have this to start the form:
<cfform action="#cgi.SCRIPT_NAME#" method="post">
on the page I'm currently working on, it says this:
<form method="post" name="form1" action="<cfoutput>#CurrentPage#</cfoutput>">
I see two differences--the different form actions and the fact that one is a cfform while the owther is a regular form. Do eitehr of those two differences matter?
Copy link to clipboard
Copied
Repeating what BKBK said, step 1 is to run a mail tag in isolation to make sure that works.
If the mail tag works, then start looking at your logic.
Copy link to clipboard
Copied
wycks wrote:
on the page i have where the cfmail does work, I have this to start the form:
<cfform action="#cgi.SCRIPT_NAME#" method="post">
on the page I'm currently working on, it says this:
<form method="post" name="form1" action="<cfoutput>#CurrentPage#</cfoutput>">
I see two differences--the different form actions and the fact that one is a cfform while the owther is a regular form. Do eitehr of those two differences matter?
That shouldn't matter. However, the dynamic variable, CurrentPage, is a possible source of error. How do you define it? In view of the fact that you wish to include the form, my guess is that you might have ignored the fact that functions like expandPath() and getCurrentTemplatePath() return the absolute path.
Try something like this on the form page:
<cfset rootPath = expandpath("/")>
<cfset currentTemplateAbsolutePath = getCurrentTemplatePath()>
<cfset currentTemplateRelativePath = replaceNoCase(currentTemplateAbsolutePath,rootPath,"")>
<cfset currentTemplateRelativePath = "/" & replace(currentTemplateRelativePath,"\","/","all")>
<cfoutput><form method="post" name="form1" action="#currentTemplateRelativePath#"></cfoutput>
Copy link to clipboard
Copied
Thanks a ton for all the help.
Ok, so the cfmail is working now. But now there are two problems.
First, after I submit the form, a goes to a blank page that only says: "Your Email has been sent. 'll get back to you as soon as I can" instead of back to the topic on the forum.
Second, the form is not submitting so while I am getting email notification now, the form doesn't post the reply to the topic on the forum.
Don't know if this matters, but on the main page, I'm using an include called "discussionGenRepliesInclude" that's just this:
==========================================================================
<cfif isDefined("Session.MM_Username")AND len(#Session.MM_Username#) NEQ 0>
<cfinclude template="discussionGenRepliesFORM.cfm">
<cfelse>
<cfinclude template="notLoggedIn.cfm">
</cfif>
===========================================================================
With "discussionGenRepliesForm.cfm being the code below: This is what I'm using right now:
===========================================================================
<cfset rootPath = expandpath("/")>
<cfset currentTemplateAbsolutePath = getCurrentTemplatePath()>
<cfset currentTemplateRelativePath = replaceNoCase(currentTemplateAbsolutePath,rootPath,"")>
<cfset currentTemplateRelativePath = "/" & replace(currentTemplateRelativePath,"\","/","all")>
<cfif isDefined("FORM.title")>
<cfprocessingdirective suppresswhitespace="No">
<cfmail
from="mikewycklendt@mymindsnotright.com"
subject="Subject"
server="scriptmail.intermedia.net"
>This is a message from
-------------------------------------------------
Content
</cfmail>
</cfprocessingdirective>
<span class="blogtitle">Your Email has been sent.<br><br>I'll get back to you as soon as I can.
</span>
<cfelse>
<cfoutput><form method="post" name="form1" action="#currentTemplateRelativePath#"></cfoutput>
<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><input type="hidden" name="user_id" value="<cfoutput>#rsGetUserID.user_id#</cfoutput>" size="32"></td>
</tr>
<tr valign="baseline">
<td align="right" nowrap class="bloguserandwho">Username:</td>
<td><input type="hidden" name="username" id="username" value="<cfoutput>#Session.MM_Username#</cfoutput>" size="32" /> <cfoutput>#Session.MM_Username#</cfoutput>
</td>
</tr>
<tr valign="baseline">
<td align="right" nowrap class="bloguserandwho">Title:</td>
<td><input 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><input type="submit" value="Post Reply"></td>
</tr>
</table>
<input type="hidden" name="reply_id" value="<cfoutput>#IncrementValue(rsReplyRecordCount.RecordCount)#</cfoutput>">
<input type="hidden" name="post_id" value="<cfoutput>#URL.post_id#</cfoutput>">
<input type="hidden" name="board_id" value="1">
<input type="hidden" name="date" value="<cfoutput>#now()#</cfoutput>">
<input type="hidden" name="MM_InsertRecord" value="form1">
</form>
</cfif>
Copy link to clipboard
Copied
wycks wrote:
First, after I submit the form, a goes to a blank page that only says: "Your Email has been sent. 'll get back to you as soon as I can" instead of back to the topic on the forum.
The code is behaving as it should. From what you described, the action page of the form (which is also where cfmail is processed) is the same as the page containing the form.
Do you mean by 'the topic of the forum' the main page in which the form page is included? If so, and if you want the form to be posted to it, then delete the block
<cfset rootPath = expandpath("/")>
<cfset currentTemplateAbsolutePath = getCurrentTemplatePath()>
<cfset currentTemplateRelativePath = replaceNoCase(currentTemplateAbsolutePath,rootPath,"")>
<cfset currentTemplateRelativePath = "/" & replace(currentTemplateRelativePath,"\","/","all")>
and use instead
<cfoutput><form method="post" name="form1" action="#CGI.SCRIPT_NAME#"></cfoutput>
Second, the form is not submitting so while I am getting email notification now, the form doesn't post the reply to the topic on the forum.
The form is definitely submitting. The fact that you get e-mail means isDefined("FORM.title") is true, which in turn means the form is submitted. My question is, how would you draw any conclusion about the form variables without outputting any of them in the mail?
Copy link to clipboard
Copied
Do you mean by 'the topic of the forum' the main page in which the form page is included? If so, and if you want the form to be posted to it, then delete the block
Yes, that's what i mean
The form is definitely submitting. The fact that you get e-mail means isDefined("FORM.title") is true, which in turn means the form is submitted. My question is, how would you draw any conclusion about the form variables without outputting any of them in the mail?
At first, the page would update and the content of the forms would automatically show up on that same page, but I never got an email. Then I changed it to what I posted above and i did get an email. I didn't care about including ther variables because i just wanted to see if anything would be sent to my email.
So now I'm using this below, and the reply does post to the page, but I'm not getting an email anymore.
================================================================================
<cfoutput><form method="post" name="form1" action="#CGI.SCRIPT_NAME#"></cfoutput>
<cfif isDefined("FORM.title")>
<cfprocessingdirective suppresswhitespace="No">
<cfmail
from="mikewycklendt@mymindsnotright.com"
subject="Subject"
server="scriptmail.intermedia.net"
>This is a message from
-------------------------------------------------
Content
</cfmail>
</cfprocessingdirective>
<span class="blogtitle">Your Email has been sent.<br><br>I'll get back to you as soon as I can.
</span>
<cfelse>
<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><input type="hidden" name="user_id" value="<cfoutput>#rsGetUserID.user_id#</cfoutput>" size="32"></td>
</tr>
<tr valign="baseline">
<td align="right" nowrap class="bloguserandwho">Username:</td>
<td><input type="hidden" name="username" id="username" value="<cfoutput>#Session.MM_Username#</cfoutput>" size="32" /> <cfoutput>#Session.MM_Username#</cfoutput>
</td>
</tr>
<tr valign="baseline">
<td align="right" nowrap class="bloguserandwho">Title:</td>
<td><input 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><input type="submit" value="Post Reply"></td>
</tr>
</table>
<input type="hidden" name="reply_id" value="<cfoutput>#IncrementValue(rsReplyRecordCount.RecordCount)#</cfoutput>">
<input type="hidden" name="post_id" value="<cfoutput>#URL.post_id#</cfoutput>">
<input type="hidden" name="board_id" value="1">
<input type="hidden" name="date" value="<cfoutput>#now()#</cfoutput>">
<input type="hidden" name="MM_InsertRecord" value="form1">
</form>
</cfif>
Copy link to clipboard
Copied
Simplify the code you've just given like this, and try again:
<cfif isDefined("FORM.title")>
<cfmail
from="mikewycklendt@mymindsnotright.com"
subject="Subject"
server="scriptmail.intermedia.net"
>
This is a message from
-------------------------------------------------
Content
</cfmail>
<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#">
<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>
Copy link to clipboard
Copied
still posts, but isn't sending any emails.
as i said in the above message posted on
Nov 23, 2012 12:12 PM in reply to BKBK
the email sends, but isn't inserting the record into my database.
with the code you just posted, the record is being inserted in the database but I don't get an email.
So one posts the reply but doesn't send an email and the other sends the email but doesn't post the reply.
again, I'm working on this page:
http://mymindsnotright.com/discussionGenReplies.cfm?post_id=21&CFID=34478875&CFTOKEN=27776971
Copy link to clipboard
Copied
Temporarily comment out the cfmail tag. Run in its place <cfdump var="#form#">. What do you get after submitting the form?
Copy link to clipboard
Copied
the records are being inserted, so i know the form is working and that the reply does show up on the topic, but the problem im having is getting the cfmail to work AND getting the reply to show up on the page after the reply is submitted.
I took out the cfmail tag and replaced it with the cfdump and nothing changes--obviously, i'm not getting an email, but the form is working properly as the reply does show up on the topic. With the cfdump in place of the cfmail, the same exact thing happens with the cfmail tag and without the cfdump---i'm seeing nothing different.
Copy link to clipboard
Copied
wycks wrote:
I took out the cfmail tag and replaced it with the cfdump and nothing changes--obviously, i'm not getting an email, but the form is working properly as the reply does show up on the topic. With the cfdump in place of the cfmail, the same exact thing happens with the cfmail tag and without the cfdump---i'm seeing nothing different.
Just to be clear, is the form structure dumped or not?
Copy link to clipboard
Copied
as I said--in an above post, the cfmail tag works but no records are inserted into the database table
Copy link to clipboard
Copied
I think I have found the cause of the problem. The code you gave above for the "larger page"(see 6. wycks) can be summarized as:
...
something, something, something
...
<cfif IsDefined("FORM.MM_InsertRecord") AND FORM.MM_InsertRecord EQ "form1">
...
<cflocation url="discussionGenReplies.cfm?post_id=#FORM.post_id#">
...
</cfif>
...
<cfinclude template="discussionGenRepliesFORMinclude.cfm">
...
When the form is submitted to this page, isDefined("FORM.MM_InsertRecord") AND FORM.MM_InsertRecord EQ "form1" becomes true. Coldfusion accordingly redirects execution to discussionGenReplies.cfm. There is therefore no opportunity to run the cfmail tag in discussionGenRepliesFORMinclude.cfm.
Now, a possible solution. You might want to move the cfmail tag to this main page, before the cflocation tag. Or else include the form page before the cflocation tag.
Copy link to clipboard
Copied
it's all working.
my next step is to see if i can figure out how to send email notifications to every person who has replied to the topic... i've alreafdy got it notifying the person who posted the topic, which is what i've been struggling with the past few days.,
Copy link to clipboard
Copied
Glad to hear it's all working. Good luck with the rest.
Copy link to clipboard
Copied
never mind. i think i got it figured out now.
thanks again,
Mike