15 Replies Latest reply on Nov 5, 2007 10:33 AM by (east99)

    insert record and email

      Hello

      How do I insert a record with the image filename into a database, then send the data just entered as an email?

      I was able to do this before but now this new CS3 seems so complicated!
      I am unable to just use an insert record behavior then add form fields and change the insert or update recored behavior like before.

      Please can I be shown some actual working tutorials on this?
      This search function on this forum does not work as I tried to search for this exact statement "insert record and email" and no records appear.

      Cheers
        • 1. Re: insert record and email
          Günter Schenk Level 4
          Hi,

          I suggest sending the email incl. file attachment from the redirect page you defined for your Insert Record Transaction -- in order to retrieve the just submitted record on that page, your Insert Record page will have to pass an additional parameter/value to that page, which contains the table´s primary key column.

          Example: "after inserting, go to": sendmail.php?id={id} (where "id" equals the table´s primary key column)

          Well, on the sendmail.php page you´ll basically just need to create a query to retrieve the latest record, e.g.

          "SELECT column_one, column_two, image_column FROM your_table WHERE id" equals the URL variable "id"

          ...and use "image_column" (containing the file name) as source for defining the attachment

          -------
          I was able to do this before but now this new CS3 seems so complicated!
          -------

          yes, it admittedly takes some time getting used to how ADDT works -- but whatever extension you´re using, there´s always some more or less steep learning curve to be expected. ADDT is quite a mighty tool providing many components, so I can only suggest to start with some basics which are explained in the official tutorials (see "ADDT tutorials" on these forum´s main page)

          --------
          This search function on this forum does not work as I tried to search for this exact statement "insert record and email" and no records appear
          --------

          well, probably just because noone ever submitted a post containing this wording yet :-)

          Cheers,
          Günter Schenk
          Adobe Community Expert, Dreamweaver
          • 2. Re: insert record and email
            Level 1
            Thanks.

            If only CS3 could allow me to use my old extensions.
            This would have been so much easier, instead of having to learn a whole new system.
            Anyways, this developer toolbox is broken.

            I have a form on my page with my designed layout and when I use the insert record behavior it does not work.
            It does not insert the record - only refreshes the page.

            Any ideas?
            • 3. Re: insert record and email
              Günter Schenk Level 4
              Hi,

              --------
              If only CS3 could allow me to use my old extensions.
              This would have been so much easier, instead of having to learn a whole new system
              --------

              Well, I know what you´re talking about, and I agree of course. IMHO you´d rather keep nagging the "Pure PHP Upload 2" vendors until they provide a working extension -- as *they* claim that their extension works on CS3, then it´s up to them to provide an update or a patch.

              I think that this might indeed be the better solution rather than learning a new system -- better stick with what you know.

              -------
              Anyways, this developer toolbox is broken
              -------

              I recall a similiar "is broken" post from you in the previous thread, what didn´t turn true after all :-)

              --------
              It does not insert the record - only refreshes the page.

              Any ideas?
              --------

              Did you define a redirection page ?

              However, you´re just using ADDT the very first day and apparently (?) didn´t walk through the basic tutorials and all -- honestly said, *if* you are interested in working with ADDT, you´ll see that certain things will take some time to becoome fully understood respectively implemented. However, ADDT is certainly not "broken", as in particular what you´re about to do (image upload etc) usually works well for others.

              Cheers,
              Günter Schenk
              Adobe Community Expert, Dreamweaver
              • 4. Re: insert record and email
                Level 1
                Hi

                Yes I did define a redirection page.

                I followed two tutorials the one was the contact form
                and the other the image gallery.

                contact form:
                http://www.adobe.com/devnet/dreamweaver/articles/addt_contact_form.html

                image gallery:
                http://www.adobe.com/devnet/dreamweaver/articles/addt_image_gallery_pt1_print.html

                The problem is that when I create my own forms and use my own layout it does not work and only refreshes the page - even though I used thanks.php as a redirect page.

                Cheers
                • 5. Re: insert record and email
                  Günter Schenk Level 4
                  Hi,

                  -----
                  The problem is that when I create my own forms and use my own layout it does not work and only refreshes the page
                  -----

                  the forms created by ADDT contain lots of special mark-up (e.g. labels) plus embed several ADDT proprietary PHP & Javascript routines for e.g. client-side / server side validation, redirects etc etc -- guess that your custom-made forms are not using all this extra stuff, and this will assumingly make them incompatible with ADDT at various points.

                  That said, I suggest to either apply DW´s native database/form handling to your own forms, or have ADDT´s Wizards create the forms for you in order to retain the desired functionality. As ADDT´s form layout is driven by CSS, it´s also possible to edit the underlying CSS files to adapt them to your page layout -- though this is a little complicated to do and will require some knowledge of CSS, but ADDT´s CSS files contain lots of comments to help you understand what class will affect what form element.

                  Cheers,
                  Günter Schenk
                  Adobe Community Expert, Dreamweaver
                  • 6. Re: insert record and email
                    Level 1
                    Thanks, but this Adobe developer toolbox isn't any good.

                    It adds it's own attribute in the form tag when you use the insert record form wizard:
                    "action=""

                    It does nothing when you use the insert record transaction.

                    I would suggest that whoever built it - fix it.

                    Cheers
                    • 7. Re: insert record and email
                      Günter Schenk Level 4
                      Hi,

                      ------
                      It adds it's own attribute in the form tag when you use the insert record form wizard:
                      "action=""
                      ------

                      sure, that´s how it internally works -- there´s no point in discussing ADDT´s way of handling these things.

                      -------
                      It does nothing when you use the insert record transaction
                      -------

                      this might happen for various reasons, but unless you post a link to that page and/or provide additional information, your "bug reports" are sort of useless.

                      ------
                      Thanks, but this Adobe developer toolbox isn't any good
                      ------

                      well, honestly, if this is what you think, then I can only suggest to not use it at all -- you´re currently using a trial version anyway, so you aren´t forced to use it, and you haven´t lost anything.

                      I have to say this :: if you´re really looking for help, please consider providing more precise information, and - as I said above - let us see the page in question -- if possible, have us look at the page *code*, because usually here´s where things go wrong.

                      You might be well frustrated about something not working, but your current way of reporting stuff would require us to be fortune tellers rather than analysts :-)

                      Cheers,
                      Günter Schenk
                      Adobe Community Expert, Dreamweaver
                      • 8. Re: insert record and email
                        Level 1
                        Ok, here is the entire page: <br /> <br /><?php require_once('Connections/cnreviva.php'); ?> <br /><?php<br />// Load the common classes<br />require_once('includes/common/KT_common.php');<br /><br />// Load the tNG classes<br />require_once('includes/tng/tNG.inc.php');<br /><br />// Make a transaction dispatcher instance<br />$tNGs = new tNG_dispatcher("");<br /><br />// Make unified connection variable<br />$conn_cnreviva = new KT_connection($cnreviva, $database_cnreviva);<br /><br />$editFormAction = $_SERVER['PHP_SELF'];<br />if (isset($_SERVER['QUERY_STRING'])) {<br />  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);<br />}<br /><br />// *** Mail form as Text format ***<br />if (isset($_POST["FX_sendForm"]) && $_POST["FX_sendForm"] == "frmupload") {<br />  $format = strtolower("Text");<br />  if ($format != "html") $format = "plain";<br />  $filefield = "uploadfile";<br />  $top = "\r\n";<br />  $body = "\r\n";<br />  $excludeArray = array("button","button_x","button_y","uploadfile","FX_sendForm","MM_insert","MM_update"); <br />  $i = 0;<br />  while ($i<sizeof($_POST)) {<br />    if (!in_array(key($_POST),$excludeArray)) {<br />      if (is_array(pos($_POST))) {<br />        $postVar = implode(", ", pos($_POST));<br />      } else {<br />        $postVar = pos($_POST);<br />      } <br />      $body .= strtoupper(key($_POST)) . ": " . stripslashes($postVar) . "\r\n";<br />    }<br />    $i++;<br />    Next($_POST);<br />  }  <br />  $bottom = "\r\n";<br />  $from = $_POST["email"];<br />  // set parameters<br />  $recipient = "email@domain.com";<br />  $subject = "Test";<br />  $message = $top . $body . $bottom;<br />  // set extra parameters<br />  $headers = "From:" . $from . "\r\n";<br />  $headers .= "Cc:\r\n";<br />  $headers .= "Bcc:\r\n";<br />  require_once("FXInc/FX_mailForm_php.inc");<br />  // send all<br />  mail($recipient, $subject, $message, $headers);<br />  $body = urlencode(str_replace("\r\n", "<br>", $body));<br />  $redirect = "thankyou.php";<br />  if ($redirect) header("Location: " . $redirect);<br />}<br /><br />// Make an insert transaction instance<br />$ins_tblfeedback = new tNG_insert($conn_cnreviva);<br />$tNGs->addTransaction($ins_tblfeedback);<br />// Register triggers<br />$ins_tblfeedback->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "POST", "KT_Insert1");<br />$ins_tblfeedback->registerTrigger("END", "Trigger_Default_Redirect", 99, "thankyou.php");<br />// Add columns<br />$ins_tblfeedback->setTable("tblfeedback");<br />$ins_tblfeedback->addColumn("name", "STRING_TYPE", "POST", "");<br />$ins_tblfeedback->addColumn("email", "STRING_TYPE", "POST", "");<br />$ins_tblfeedback->addColumn("city", "STRING_TYPE", "POST", "");<br />$ins_tblfeedback->addColumn("country", "STRING_TYPE", "POST", "");<br />$ins_tblfeedback->addColumn("shoe_size", "STRING_TYPE", "POST", "");<br />$ins_tblfeedback->addColumn("feedback", "STRING_TYPE", "POST", "");<br />$ins_tblfeedback->addColumn("activate", "STRING_TYPE", "POST", "", "N");<br />$ins_tblfeedback->addColumn("photo", "FILE_TYPE", "FILES", "uploadfile", "");<br />$ins_tblfeedback->setPrimaryKey("id", "NUMERIC_TYPE");<br /><br />// Execute all the registered transactions<br />$tNGs->executeTransactions();<br /><br />// Get the transaction recordset<br />$rstblfeedback = $tNGs->getRecordset("tblfeedback");<br />$row_rstblfeedback = mysql_fetch_assoc($rstblfeedback);<br />$totalRows_rstblfeedback = mysql_num_rows($rstblfeedback);<br />?> <br /> <br /> <br /> <br /> <br /> <br /> <script src="includes/common/js/base.js" type="text/javascript"></script> <br /> <script src="includes/common/js/utility.js" type="text/javascript"></script> <br /> <script src="includes/skins/style.js" type="text/javascript"></script> <br /> <br /> <br /> <br /> <form action="%3C?php%20echo%20$editFormAction;%20?%3E" method="post" name="frmupload" id="frmupload"> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <table width="300" border="0" cellspacing="0" cellpadding="5"> <tr> <td>Name <br /> <br /> <input type="text" name="name" id="name" length="20" value="" /></td> </tr> <tr> <td>Email <br /> <br /> <input type="text" name="email" id="email" length="20" value="" /></td> </tr> <tr> <td>City <br /> <br /> <input type="text" name="city" id="city" length="20" value="" /></td> </tr> <tr> <td>Country <br /> <br /> <input type="text" name="country" id="country" length="20" value="" /></td> </tr> <tr> <td>Image <br /> <br /> <input name="uploadfile" type="file" id="uploadfile" /></td> </tr> <tr> <td>&#160;</td> </tr> <tr> <td> <?php<br /> echo $tNGs->getErrorMsg();<br />?> <input type="submit" name="button" id="button" value="Submit" /> </td> </tr> </table> <br /> <input type="hidden" name="FX_sendForm" value="frmupload" /> <br /></form> <br /> <p>&#160;</p> <br /> <br />
                        • 9. Re: insert record and email
                          Günter Schenk Level 4
                          Ok, I see, thanks...

                          you seem to use another extension (FX_sendForm) for sending the mail, and I fear that this certainly "ADDT incompatible" extension breaks the Insert Record Transaction -- one good example is the fact that "FX_sendForm" uses its own $redirect = "thankyou.php"; routine, and this will of course conflict with ADDT´s redirection.

                          ADDT always works well when applying its own "custom triggers" (here´s where you can define the "execution order" of whatever triggers you triggers), but trying to hook in some some functionality provided by external extensions is not supported. In so far ADDT is a sort of "closed system" which restricts you to using its own methods, but this applies to similar extensions like "WebAssist" as well.

                          However, in order to stay out of such incompatibility-related trouble, I´d rather suggest to send the email from "thankyou.php" -- and in order to retrieve the most recently added record there, you´ll have to pass the URL parameter "id" plus the current primary key to that page as well. More precisely, the "Trigger_Default_Redirect" line would have to link to that page this way:

                          $ins_tblfeedback->registerTrigger("END", "Trigger_Default_Redirect", 99, "thankyou.php?id={id}");

                          Cheers,
                          Günter Schenk
                          Adobe Community Expert, Dreamweaver
                          • 10. Re: insert record and email
                            Level 1
                            You see the tutorials that I have read, have no mention of editing the code direct.

                            Also the knowledge base or the help file that you get with these extensions is minimal.

                            Man, I don't know if buying this is worth while.

                            I have developed many sites in less time than trying to figure out how things are or aren't supposed to work - because they all just work.

                            I really don't know...
                            This is so complicated.

                            But thanks anyway.
                            • 11. Re: insert record and email
                              Level 1
                              This is one site that I developed without any fancy extensions - just plain old PHP coding.

                              http://www.reviva.co.za/

                              Enjoy.
                              • 12. Re: insert record and email
                                Günter Schenk Level 4
                                ------
                                You see the tutorials that I have read, have no mention of editing the code direct.
                                ------

                                you wouldn´t have had to edit that code directly -- I just wanted to provide a code-based "shortcut" for something that could also be done by using the respective DW/ADDT server behaviour interface.

                                -------
                                Also the knowledge base or the help file that you get with these extensions is minimal.
                                -------

                                I agree, this is a weak point especially for newbies. The problem with ADDT´s documentation & tutorials is :: since Adobe bought Interakt (the makers of ADDT´s predecessor "MX Kollection"), it´s all scattered to the four winds, if you will. Some of the elementary tutorials are available at the Adobe website, and some more advanced tips & tricks (though no fully fledged tutorials) have been assembled at the InteraktOnline "MX Kollection" forums -- regular users did so far not contribute anything of real value, but fortunately Waleed Barakat is now creating some *very* good tutorials.

                                -------
                                Man, I don't know if buying this is worth while.

                                I have developed many sites in less time than trying to figure out how things are or aren't supposed to work - because they all just work
                                ------

                                seems you´re in fact answering your own question :-)

                                ------
                                I really don't know...
                                This is so complicated
                                ------

                                Yes, learning how to use ADDT can be complicated -- but what do you expect from a huge "framework" that´s providing plenty of features under "one roof", but in return will require users to understand (and accept) the way it works, respectively learning/accepting what it *can´t* do ?

                                Don´t know if you ever tried to get a - in terms of features - similarly huge PHP Application Framework (e.g. CakePHP) to work for you -- well, you would have to learn this one too until you´re able to tap its full potential, and you´d also soon notice that all "frameworks" out there sort of "force" you into using their built in methods.

                                I can´t and won´t try talking you into using ADDT at all. If you feel that your familiar workflow actually serves you better, then you´re by all means probably better off sticking to this -- I personally use to hand code stuff as well in case *whatever* extension won´t let me do what I want to, and at times I have ADDT create page A and code page B myself.

                                Cheers,
                                Günter Schenk
                                Adobe Community Expert, Dreamweaver
                                • 13. Re: insert record and email
                                  Level 1
                                  I have googled his name, it seems that he has got a grip on this adobe stuff.
                                  I guess I will have to find some books or good tuts on this adobe setup.

                                  It's not fun trying to ask a question that shouldn't be asked, I mean if the button says "send email" then the program should send the email, or in this case allow the developer to develop the form and method to allow users to send an email.

                                  I never really liked the Interakt stuff, I prefer the standard "insert record behavior" and so on.

                                  Cheers and thanks.
                                  • 14. Re: insert record and email
                                    Günter Schenk Level 4
                                    -----
                                    It's not fun trying to ask a question that shouldn't be asked, I mean if the button says "send email" then the program should send the email, or in this case allow the developer to develop the form and method to allow users to send an email
                                    -----

                                    true -- but you can´t expect to always have different functionality (inserting a record plus sending an email) available within just one page (at least not with DW), and rolling functions provided by different extensions (which, like in your case, are incompatible with each other) into one can´t be expected to work.

                                    I *never* had any problems when executing ADDT´s "Send Email" function from the "redirect after success" page, and I honestly think that reconsidering your corresponding workflow could be worthwile.

                                    ------
                                    I never really liked the Interakt stuff, I prefer the standard "insert record behavior" and so on
                                    ------

                                    Alright, then simply don´t continue working with ADDT :-)

                                    Cheers,
                                    Günter Schenk
                                    Adobe Community Expert, Dreamweaver
                                    • 15. Re: insert record and email
                                      Level 1
                                      ... but you can´t expect to always have different functionality
                                      ...(inserting a record plus sending an email) available within just
                                      ...one page (at least not with DW),

                                      You can.
                                      If you use the http://www.felixone.it/ Mail Form extension, been doing it for years.

                                      Cheers