Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

my CFMAIL doesn't work properly.

Posted on 2012-03-15
3
Medium Priority
?
314 Views
Last Modified: 2012-03-26
Hello,

I have a coldfusion which display information from a SQL database.  I've add a function of CFMAIL that everytime the use click the button 'update' the new record will update the database and send an email.

But i have a problem everytime i refresh that page an email will be sent... What I want that everytime the user CLICK the 'update' button an email should be generated.

thank you

HEre is m code:

I know i should put an if but i'm using form post please see my code.

            <form action="update_account_info_e.cfm?Task=UpdateInfo" method="post">
            
            <table border="0" cellspacing="0" cellpadding="0" width="100%" class="qtable">
            <tr>
            <td align="right" bgcolor="78A8D2" width="50%"><font color="white" size="2"><font face="arial" size="2"><b>First Name: </b></font></td>
            <CFOUTPUT>
            <td ALIGN="LEFT" width="50%"><font size="3"><input type="text" name="firstname" value="#DisplayUser.firstname#"> </font></td>
            </CFOUTPUT>

</form>

   <CFMAIL FROM="abc@datanet.ca"
      SERVER="mail.abc.ca"
      SUBJECT="Test Update"
      TO="status@datanet.ca">
      The following information is sent by this client, please
      respond accordingly
      At #DateFormat(now(),
      'mmm dd, yyyy')# #TimeFormat(now(),
      'hh:mm tt')#,
      Name: #DisplayUser.lastname#      
      </CFMAIL>
0
Comment
Question by:LelloLello
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 

Author Comment

by:LelloLello
ID: 37726251
how can I put this if

<cfif Task eq "email">

Where in my code, please open my code.  and how i should call the email.

So only the if they update the info an email should go. currenlty everytime i load that page an  email is send :(.
update.txt
0
 
LVL 39

Accepted Solution

by:
gdemaria earned 2000 total points
ID: 37726473
You can put the cfmail into the file..  update_account_info_e.cfm
which is where you do the update.  Then only when the update happens, the email will send.
Is the update happening every time the page is refreshed as well?  it must be if the emial is sent.


You need to add a submit button, you can test for submit by checking for the name of the submit button..

<cfif isDefined("form.submit")>
    ... do your update
    ... send your email
    ... use cflocation to redirect to a new page
</cfif>
0
 

Author Comment

by:LelloLello
ID: 37767352
thank you.
0

Featured Post

Use Filtering Commands to Process Files in Linux

Learn how to manipulate data with the help of various filtering commands such as `cat`, `fmt`, `pr`, and others in Linux.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article  is about submitting  form through  ColdFusion.Ajax.submitForm to the action page and send a response back in JSON format which later can be decoded using ColdFusion.JSON.decode. By this way you can avoid the usual page refresh for subm…
CFGRID Custom Functionality Series -  Part 1 Hi Guys, I was once asked how it is possible to to add a hyperlink in the cfgrid and open the window to show the data. Now this is quite simple, I have to use the EXT JS library for this and I achiev…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question