Hi there,
I have developed (with some invaluable and greatly appreciated help!) a comment box using Java script (see bottom of this page http://www.antobbo.webspace.virginmedia.com/webediting/documents.htm) but I would like now to be able to receive comments via email. At the moment if you click on the comment button it opens the comment box (which is great) but if you type something and click "send" it opens outlook and try to send an email to the specified address. Upon clicking "Send" I would like the comment to be sent automatically to the email address specified.
Now, I have done some research and looked around a bit and from what I gathered I need to have a PHP script that handles the comment and a database where the comment gets kept to be then called by the script and dealt with..or something like that. Granted that I have no experience in either Java script (this is the first script I ever done) or in PHP (never done anything) I wonder if you have any other suggestion on how to achieve the above.
Is there, say, any library that I could use so that the comment input by the users gets somehow automatically handled or do I have to write the PHP script myself?

Also I read that a lot depends on the internet provider as well, in so much so that if their server do not support PHP then I have to find another way.

So, in brief is there an alternative way?
If not, and I have to do that myslef, what do I exactly need to do?
Is it really difficult to write a script in PHP that handles the comment? That done what else?
If anybody could give me a details explanation of what needs to be done that'll be greatly appreciated.
Thanks

Recommended Answers

All 6 Replies

“or do I have to write the PHP script myself” don’t be so opposite about it. PHP is a programming language, yes it is interpreted in C and yes can be used as nonsense ( but all programming languages can be used that way ) . Maybe is the time to learn a bit more of how things are moving …

PHP is not too difficult depending on your programming experience. If you were familiar with another language derived from C then you would probably catch on to PHP rather quickly. If you really only know Javascript then you may have to rewire your thinking a bit to handle a server side language rather than a client side language like Javascript.

Most website hosts support PHP, it is a standard these days. You can easily check to see if the server supports PHP by just creating a file with a ".php" extension on the end and then in the file somewhere put <?php echo "Hello World"; ?> and if it just says "Hello World" then you are good to go.

A PHP mail form is probably one of most typical first reasons someone starts messing with PHP. Using the mail function is not hard at all but the complexity of a mail form can range depending on the information being sent and the logic that is being built into it for error handling etc.

Really your comment box is no different than an email form and is actually a little simpler because it only has one input field for a comment. Try taking a look online for "Sending email with PHP" and finding some tutorials on it. A lot of them are very informative and break down the whole process to be easily understandable. Here is a site that shows how to send 3 different types of data through the mail function in PHP http://www.webcheatsheet.com/PHP/send_email_text_html_attachment.php

Once you start messing around with this and you get your own script going if you run into any problems start a thread on the forums and show us your code :)

Member Avatar for diafol

I'd avoid the email client myself. It annoys me that I have to get involved with my client to post a comment. As mentioned, a comment form that sends the info to you via email is preferable. Better still the comment should be stored in a DB with an inactive status field. You then peruse all new comments and check the ones you approve - this changes the comment status to active. This should be easier to maintain.

PHP is not too difficult depending on your programming experience...

I am actually studying C++, so I know the basics.
I will try with the .php test file even if I think it should be ok, Virgin is hosting my website I assume their servers are ok with PHP.
I will then have a look at your link and try to make the script and then see how it goes. So just to be sure, the PHP script is all I need to make my comment box idea work, no need for anything else?

Yes, PHP is all you need to send the email with the form data from your comment box.

Once you get it working you could spice it up some with AJAX if you wanted to send the form data asynchronously to the PHP script so the page doesn't have to refresh :) But that is a whole new ball of wax.

Cheers!

Brilliant, thanks a lot, I will have a go, sure will be posting here again soon : - )

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.