A Flash Developer Resource Site

Page 1 of 3 123 LastLast
Results 1 to 20 of 54

Thread: Add comment

  1. #1
    Senior Member littleMatt's Avatar
    Join Date
    Apr 2004
    Posts
    1,148

    Add comment

    How can I make an add comment pop window on a site?

    Do I need a database or is there a way to do it without one, preferably free! Google isn’t giving me any love, nor the Dreamweaver Forum on Macromedia.com

    I tried one from haloscan.com a short while ago but it simply didn’t work!

  2. #2
    ? tonytryout's Avatar
    Join Date
    Oct 2001
    Location
    Somewhere out there
    Posts
    864
    Depends on what server-side language your server supports, e.g. PHP or ASP.

    There are two ways -- if the comments is to be reviewed by you only then email would suffice (e.g. free CDONTS or CSYS email component for ASP) but if you want the comments to be available for the public and it is displayed automatically after the person submits it then you would need database like SQL or mySQL.

    You can use MS Access but if I rememeber correctly, it can only handle something like 3 concurrent users.

  3. #3
    Senior Member littleMatt's Avatar
    Join Date
    Apr 2004
    Posts
    1,148
    I think it uses ASP, and to run an SQL database would cost me an extra £50 a year (not that I know what ASP or SQL means).

    It would be preferable that comments were publicly displayed. Is there a Mac version to MS Access

    Sorry, never had anything to do with databases before so not sure how to go about things like this!

  4. #4
    ? tonytryout's Avatar
    Join Date
    Oct 2001
    Location
    Somewhere out there
    Posts
    864
    MS SQL is not cheap unfortunately but maybe your host can provide MS Access version for free or at little cost?

    Failing that, you could get the comments to be emailed to you where you can then add the comments to a page yourself. Not too practical, I know but this is a "free" solution at least.

    To make it even easier, you could put in a SSI (server-side includes) function on a page and your text file (or even XML) could contain comments and easily modified by yourself.

    Another "free" solution is to do a file write where the comments are saved to a pre-defined XML file after the submission of a form but I don't think your host would provide a write access -- correct me if I am wrong...

    Let me know which one you want to go with, and I can show you how it works...

  5. #5
    Senior Member littleMatt's Avatar
    Join Date
    Apr 2004
    Posts
    1,148
    Quote Originally Posted by tonytryout
    To make it even easier, you could put in a SSI (server-side includes) function on a page and your text file (or even XML) could contain comments and easily modified by yourself.

    Another "free" solution is to do a file write where the comments are saved to a pre-defined XML file after the submission of a form but I don't think your host would provide a write access -- correct me if I am wrong...
    What sort of access would I need? My host is pretty kool, so he might allow me.

    But the SSI thing sounds good, like I say I'm useless with coding, so if it would be more understandable that would be good

    Thanks

  6. #6
    ? tonytryout's Avatar
    Join Date
    Oct 2001
    Location
    Somewhere out there
    Posts
    864
    Sure. There are two ways of doing this -- static or dynamic.

    Static: Using SSI
    Create a ASP webpage named "comments.asp" as normal (like HTML file but the extension is .asp) with your branding, etc.. And in a place where you want the comments to appear:
    Code:
    <!--#include file="comments_text.htm"-->
    And use a simple email component like CDONTS where the person sends his/her comments to you and then you add it to the page "comments_text.htm". You can leave "comments.asp" alone as the content is all taken care of by "comments_text.htm" file.

    SSI is a great feature and I use it for database connection strings, form validation rules, etc. so if you need to change something then all you need to do is change one file. The rest of the files remain untouched and updated automatically.

    You can even use it for simpler things like copyright date, or even branding header -- both which I use for my portfolio site (www.fenka.co.uk). You don't actually see the SSI tag because the server renders it.

    And now...
    Dynamic: Writing files
    This is a bit more complicated so maybe this explains it better!

    So basically, the process is as follows:
    1- Data is submitted
    2- Check data (validation, check comments is empty?, etc.)
    3- If ok, move to stage 5, otherwise 4.
    4- Produce error. Go back to 1.
    5- Start file writing/appending process to a file say comments.xml

    My XML is a bit rusty since writing my dissertation so this may help -- there are some samples that you can use from that.

    Hope this helps but if you have any further queries, let me know.

  7. #7
    ? tonytryout's Avatar
    Join Date
    Oct 2001
    Location
    Somewhere out there
    Posts
    864
    just had a thought.... do you know how to create a (server-side) form?

  8. #8
    Senior Member littleMatt's Avatar
    Join Date
    Apr 2004
    Posts
    1,148
    I’ve created the comments.asp page with the wanted text fields then ignorance kicked in. I googled CDONTS but wasn’t sure what to do with it sorry! I found a tutorial on it, but the first line said something like “If you’re reading this I’ll assume you know your way around ASP etc” which discouraged me somewhat, as I don’t.

    How do I tell the submit button to email the text over, and is there a way that it can tell what page it has been sent from – homepage.html, pictureOfMyDog.html etc?

    No I don't know how to create a server side form - sorry man, I bet you wished you'd never answered me now lol

  9. #9
    ? tonytryout's Avatar
    Join Date
    Oct 2001
    Location
    Somewhere out there
    Posts
    864
    lol

    ok, I have created a basic server-side form for you (not exactly accessibility-friendly but what the helli:
    Code:
    <form action="comments.asp" method="post" name="frmComments">
                  <table width="100%" border="0" cellspacing="2" cellpadding="2">
                    <tr align="left" valign="top"> 
                      <td colspan="2"><h4>COMMENTS</h4></td>
                    </tr>
                    <tr align="left" valign="top"> 
                      <td><h4>Name</h4></td>
                      <td><p>
                        <input name="Name" type="text" id="Name" size="30">
                      </p></td>
                    </tr>
                    <tr align="left" valign="top"> 
                      <td><h4>Comments</h4></td>
                      <td><p>
                        <textarea name="Comments" cols="23" rows="4" wrap="PHYSICAL" id="Comments"></textarea>
                        <input name="send_email" type="hidden"  id="send_email" value="true">
    </p></td>
                    </tr>
                    <tr align="left" valign="top"> 
                      <td colspan="2"><p>&nbsp;
                      </p></td>
                    </tr>
                    <tr align="center" valign="bottom"> 
                      <td colspan="2"><p>
        <input type="submit" name="Submit" value="Send">
     
                        </p></td>
                    </tr>
                    <tr align="left" valign="top"> 
                      <td colspan="2"></td>
                    </tr>
                    <tr align="left" valign="top"> 
                      <td><p>&nbsp;</p></td>
                      <td><p>&nbsp;</p></td>
                    </tr>
                  </table>
                </form></td>
            </tr>
            <tr> 
              <td height="2%">&nbsp;</td>
            </tr>
        </table>
    Now the important bit is the hidden field called send_email. The name could be anything but I used send_email just for simplicity.

    The email code itself is very simple and you can use the following (put it at the top of the page before the <html> tag:
    Code:
    <%
    if (String(Request("send_email")) != "undefined") {
    
    var objName = String(Request.Form("Name"));
    var objComments = String(Request.Form("Comments")).replace(/\n/g,"<BR>");
    
    var mainBody = "Someone used the Comments form. The details are as follows:<BR>";
    	mainBody = mainBody + "<BR><BR><b>Name:</b> " + objName
            mainBody = mainBody + "<BR><BR><b>Comments</b><BR><BR>" + String(Request.Form("Comments")).replace(/\n/g,"<BR>") + "</P><BR>";
    var endBody = mainBody + "<BR><BR>Powered by whatever";
    
    
    var objCDO = Server.CreateObject("CDONTS.NewMail");
    objCDO.To = "myemail@email.com"
    objCDO.From = "whatever@email.com"
    objCDO.Subject = "Comments"
    objCDO.Body = endBody
    objCDO.MailFormat = 0
    objCDO.BodyFormat = 0
    objCDO.Send()
    objCDO = null
    Response.Redirect("thanks.asp);
    }
    %>
    Don't forget to add the following in the first line of the asp page:
    Code:
    <%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
    This tells the server that this is a ASP page and to go ahead and render it as such.

    So your page should end up in the following order:
    1- @Language line
    2- Email code
    3- Comments form

    That will be £50 pls.

  10. #10
    ? tonytryout's Avatar
    Join Date
    Oct 2001
    Location
    Somewhere out there
    Posts
    864
    Quote Originally Posted by littleMatt
    How do I tell the submit button to email the text over, and is there a way that it can tell what page it has been sent from – homepage.html, pictureOfMyDog.html etc?
    First bit is already answered above but the bit "what page it has been sent from". How do you mean? Do you want a record of where the data was sent from?

  11. #11
    Senior Member littleMatt's Avatar
    Join Date
    Apr 2004
    Posts
    1,148
    OK, I've got all your code that makes up the form. Does this go in the comments.asp page? Or just a normal html page? And where does the email code go?

    Yeah if possible I'd like to know from which page the comment is, so I'd know exactly what the user was commenting on.

    I reckon by the time this is done you'll be wanting to charge me more than £50

  12. #12
    ? tonytryout's Avatar
    Join Date
    Oct 2001
    Location
    Somewhere out there
    Posts
    864
    No problem, I will send you an invoice!

    comments.asp is a "normal html" page so you could use comments.asp like a normal webpage that you usually create. Main differences you can easily spot: the file extension and the use of <% and %> in the source code.

    The email code is on the same page as where the form is, e.g. comments.asp.

    You could "cheat" a little but adding another hidden field for example:
    Code:
    <input name="pageinfo" type="hidden"  id="pageinfo" value="Products page">
    And in the email code, modify the line for email body:
    Code:
    var mainBody = "Someone used the Comments form. The details are as follows:<BR>";
    	mainBody = mainBody + "<BR><BR><b>Name:</b> " + objName
            mainBody = mainBody + "<BR><BR><b>Location:</b> " + String(Request.Form("pageinfo"));
            mainBody = mainBody + "<BR><BR><b>Comments</b><BR><BR>" + String(Request.Form("Comments")).replace(/\n/g,"<BR>") + "</P><BR>";
    var endBody = mainBody + "<BR><BR>Powered by whatever";

  13. #13
    Senior Member littleMatt's Avatar
    Join Date
    Apr 2004
    Posts
    1,148
    OK. So far I've used the code for the asp page (still not sure what to do with teh email code) but when I test it on my machine this happens:

    http://www.fishandonions.com/commentstest/picture-1.jpg

    and when I test it online it asks if I want to download the page:

    http://www.fishandonions.com/commentstest/

  14. #14
    ? tonytryout's Avatar
    Join Date
    Oct 2001
    Location
    Somewhere out there
    Posts
    864
    yes I see what you mean. But first things first....

    Your ASP page could have normal <html> tags. So treat your comments.asp as normal HTML file (include all usual <html>, <body>, etc. tags).

    Also the download prompt suggests to me that your server either do not support or does not render ASP correctly.

  15. #15
    Senior Member littleMatt's Avatar
    Join Date
    Apr 2004
    Posts
    1,148
    You're right. I uploaded the new (with html tags) version to my work server:

    http://www.atom.uk.com/commentstest/

    What should I say to my host?

  16. #16
    ? tonytryout's Avatar
    Join Date
    Oct 2001
    Location
    Somewhere out there
    Posts
    864
    looks like ASP works -- you don't really need to tell your host anything about this. That's if your host uses standard email component (free and comes with Windows server) then it should work.

    I have just sent you a test comment. It might be worth adding a response.redirect call just after the email code so that the user is taken to another page (e.g. a "thank you" page).

    Btw, did you receive email?

  17. #17
    Senior Member littleMatt's Avatar
    Join Date
    Apr 2004
    Posts
    1,148
    I haven't received an email - what address should it be going to?

    PS. How the HELL do I stop Dreamweaver from automatically FTPing pages that I save?

  18. #18
    ? tonytryout's Avatar
    Join Date
    Oct 2001
    Location
    Somewhere out there
    Posts
    864
    show me your ASP code. The email address is for you...

    Re dreamweaver, there is a checkbox called "automatically upload files to server on save" in Remote Info inside the site definition window (go to "Manage Sites.."

  19. #19
    Senior Member littleMatt's Avatar
    Join Date
    Apr 2004
    Posts
    1,148
    Code:
    <%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <style type="text/css">
    <!--
    -->
    </style>
    </head>
    
    <body background="http://www.fishandonions.com/images/back.jpg" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
    <form action="comments.asp" method="post" name="frmComments">
      <table width="100%" height="100%" cellpadding="0" cellspacing="0">
        <tr> 
          <td><div align="center"> 
              <table width="300" align="center" cellpadding="0" cellspacing="0">
                <tr> 
                  <td width="50"> <div align="center"> 
                      <p align="center"><span class="bodyCopy"><font color="#000000" size="3" face="Georgia, Times New Roman, Times, serif">name</font></span><br>
                        <input name="Name2" type="text" id="Name2" size="26">
                      </p>
                    </div></td>
                </tr>
                <tr> 
                  <td height="50"> <div align="center"> 
                      <p align="center"><span class="bodyCopy"><font color="#000000" size="3" face="Georgia, Times New Roman, Times, serif">email 
                        address</font></span><br>
                        <input name="Email2" type="text" id="Email" size="26">
                      </p>
                    </div></td>
                </tr>
                <tr> 
                  <td width="100"> <div align="center"> 
                      <p align="center"><span class="bodyCopy"><font color="#000000" size="3" face="Georgia, Times New Roman, Times, serif">comments</font></span><br>
                        <textarea name="textarea" cols="23" rows="4" wrap="PHYSICAL" id="textarea"></textarea>
                        <input name="send_email2" type="hidden"  id="send_email2" value="true">
                        <br>
                        <input type="submit" name="Submit" value="Send">
                      </p>
                    </div></td>
                </tr>
              </table>
            </div>
            <p align="center"> 
              <input name="pageinfo" type="hidden"  id="pageinfo2" value="Products page">
            </p></td>
        </tr>
      </table>
    </form>
    </body>
    </html>
    infoATfishandonions.com?

    Thanks, that's been bugging me for ages!

  20. #20
    ? tonytryout's Avatar
    Join Date
    Oct 2001
    Location
    Somewhere out there
    Posts
    864
    ah no. The page comments.asp should have email code AND the form in the same page.

    Code:
    <%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <%
    if (String(Request("send_email")) != "undefined") {
    
    var objName = String(Request.Form("Name"));
    var objComments = String(Request.Form("Comments")).replace(/\n/g,"<BR>");
    
    var mainBody = "Someone used the Comments form. The details are as follows:<BR>";
    	mainBody = mainBody + "<BR><BR><b>Name:</b> " + objName
            mainBody = mainBody + "<BR><BR><b>Comments</b><BR><BR>" + String(Request.Form("Comments")).replace(/\n/g,"<BR>") + "</P><BR>";
    var endBody = mainBody + "<BR><BR>Powered by whatever";
    
    
    var objCDO = Server.CreateObject("CDONTS.NewMail");
    objCDO.To = "infoATfishandonions.com"
    objCDO.From = "websiteATfishandonions.com"
    objCDO.Subject = "Comments"
    objCDO.Body = endBody
    objCDO.MailFormat = 0
    objCDO.BodyFormat = 0
    objCDO.Send()
    objCDO = null
    Response.Redirect("thanks.asp);
    }
    %>
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <style type="text/css">
    <!--
    -->
    </style>
    </head>
    
    <body background="http://www.fishandonions.com/images/back.jpg" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
    <form action="comments.asp" method="post" name="frmComments">
      <table width="100%" height="100%" cellpadding="0" cellspacing="0">
        <tr> 
          <td><div align="center"> 
              <table width="300" align="center" cellpadding="0" cellspacing="0">
                <tr> 
                  <td width="50"> <div align="center"> 
                      <p align="center"><span class="bodyCopy"><font color="#000000" size="3" face="Georgia, Times New Roman, Times, serif">name</font></span><br>
                        <input name="Name2" type="text" id="Name2" size="26">
                      </p>
                    </div></td>
                </tr>
                <tr> 
                  <td height="50"> <div align="center"> 
                      <p align="center"><span class="bodyCopy"><font color="#000000" size="3" face="Georgia, Times New Roman, Times, serif">email 
                        address</font></span><br>
                        <input name="Email2" type="text" id="Email" size="26">
                      </p>
                    </div></td>
                </tr>
                <tr> 
                  <td width="100"> <div align="center"> 
                      <p align="center"><span class="bodyCopy"><font color="#000000" size="3" face="Georgia, Times New Roman, Times, serif">comments</font></span><br>
                        <textarea name="textarea" cols="23" rows="4" wrap="PHYSICAL" id="textarea"></textarea>
                        <input name="send_email2" type="hidden"  id="send_email2" value="true">
                        <br>
                        <input type="submit" name="Submit" value="Send">
                      </p>
                    </div></td>
                </tr>
              </table>
            </div>
            <p align="center"> 
              <input name="pageinfo" type="hidden"  id="pageinfo2" value="Products page">
            </p></td>
        </tr>
      </table>
    </form>
    </body>
    </html>
    I noticed in your code, the parameters are now different (Name2, Email2, Comments2, send_email2, etc.) -- you need to make sure that the parameter names in both the code and the form are exactly the same otherwise it won't work...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center