Page 1 of Client/Server Program - Simple form on a web page...

General Forum

Client/Server Program - Simple form on a web page...

r8sso (Elite) posted this on Friday, 19th July 2002, 17:08

I would like to put a simple form on a Web-site for visitors to submit questions and comments. I would like the information to be sent to an e-mail address when the user clicks submit but I don`t want their
e-mail software to open up. I understand that this must done using some client/server programming. As I`ve never done much (any) server side web-design before I was wondering if anyone here could help me out. I know my ISP must support whatever protocol/language I choose, .asp .cgi .php etc... So, what would be the best way to go about this? I`m quite keen to learn how to use one of these as I would like to start adding some dynamic content to my site`s.

As always, thanks for your help.
Ross.

RE: Client/Server Program - Simple form on a web page...

James Saunders (Competent) posted this on Friday, 19th July 2002, 18:57

My prefered solution would be PHP, but then my site uses it extensively.

If you create a page (CommentForm.html) with a form in it, with the action set to a PHP page (MailComments.php), the variables from the form ($SenderEmail, $comment) are send as variables to the page. You can then use the PHP mail command to actually send the mail somewhere in the MailComments.php file. The mail command would look something like:
mail("ssor[at]moc.erehwemos",
"A user comment from $SenderEmail",
"$comment",
"From:ssor[at]moc.erehwemos\r\nReply-to:ssor[at]moc.erehwemos");
The next step would be to take the variables and use PHP to store them in a MySQL database table.
James @ u-rate-it

RE: Client/Server Program - Simple form on a web page...

r8sso (Elite) posted this on Friday, 19th July 2002, 19:42

Cheers James.

.php does seem to be the most popular way of doing this.

Next question, anyone know any good .php tutorials? :-)

RE: Client/Server Program - Simple form on a web page...

James Saunders (Competent) posted this on Friday, 19th July 2002, 19:57

Do a search for PHP tutorials in google. Most are pretty good, especially WebMonkey and PHPBuilder. Also, check out the book `MySQL/PHP Database Applications` if you are heading in that direction. I found it invaluable. Good luck. If you need further help, contact me via the u-rate-it site and I will do my best to help.

This item was edited on Friday, 19th July 2002, 20:06

RE: Client/Server Program - Simple form on a web page...

top_cat_38 (Competent) posted this on Friday, 19th July 2002, 21:39

You could also use ASP which is the de-facto standard for web-sites.

ASP uses CDONTS to send emails, it`s very easy.

You just need to make sure your ISP has it installed on their server.

Whichever way you go, ISP`s usually charge a premium rate if you want to send emails.

RE: Client/Server Program - Simple form on a web page...

James Saunders (Competent) posted this on Friday, 19th July 2002, 23:12

I have found generally that PHP/MySQL hosting is cheaper than the alternative Microsoft solution. That makes it very popular.

Also, with ASP.NET (Microsoft`s latest incarnation of ASP), web development has become much easier. It`s certainly a lot easier to develop in .NET that previous Microsoft languages. Having said that, you`ll pay higher prices for de-facto standard tools!

This item was edited on Friday, 19th July 2002, 23:25

RE: Client/Server Program - Simple form on a web page...

alfie noakes (Elite) posted this on Saturday, 20th July 2002, 00:30

Most isp`s will already have standard cgi form mail templates on their servers, which you would normally have easy access to. Pretty simple to use and customise. I`d have a butcher`s at your isp`s help files to see what`s available and how to go about accessing them.

RE: Client/Server Program - Simple form on a web page...

r8sso (Elite) posted this on Saturday, 20th July 2002, 09:05

Good point that alfie, just had a look and it seems they do...

" This pre installed script allows you to have the results of forms sent to you by e-mail. The commands used follow broadly the same system as the common Matt`s Formmail script except this version will only send to addresses @rossbowman.info.

Form Action : http://rossbowman.info/cgi-sys/FormMail.cgi

You also need to include a hidden field called "recipient" the value of which is your e-mail address (so the script knows where to send the results to). "

So what do I do with this script? Do I set the "action" attribute in the form to point to "http://rossbowman.info/cgi-sys/FormMail.cgi" or just "FormMail.cgi" or neither!

Thanks again.
Ross.

RE: Client/Server Program - Simple form on a web page...

alfie noakes (Elite) posted this on Sunday, 21st July 2002, 13:35

Hi r8sso

I use form mail scripts on my btconnect server. I don`t know how similar to use they would be to your script - there could be differences, but here`s an outline of how I do it:

You have to create a simple plain text document (with a .txt file extension) which is the template for the email that is sent back to you after the user has submitted their info. This document is simply uploaded to the same directory as your html files. I`ve put an example below:



To: sserdda-liame-ruoy[at]moc.revres-ruoy
Subject: Contact Information
From: [contact_name]

e-Mail address: [contact_email]

Contact number: [contact_number]

How did you find this site?: [contact_how]

What Browser do you use?: [contact_whatbrowser]

Feedback/Comments: [contact_comments]



The template has to correspond to the html form that you created. The bits in square brackets are named the same as the input boxes created in the form. They are the variables that will have the user`s submitted info when it is sent back to you as an email. Note that the To: line will have your own email address and this is where the submitted info will be automatically sent to.

The html for the form would be something like:
<form method="POST" action="http://rossbowman.info/cgi-sys/FormMail.cgi/form_template.txt">
("form_template.txt" would be the text template you created)

If it helps, have a look at the html on one of my forms http://www.northdownsironcraft.co.uk/contactus.htm

I can`t pretend that I`m much of a programmer and the method I`ve shown may well not be relevant to your server`s set up. Hope it helps anyway.

RE: Client/Server Program - Simple form on a web page...

r8sso (Elite) posted this on Sunday, 21st July 2002, 20:24

I`m trying to get the FormMail.cgi script to work which my ISP provides.

This is how it tells you to set it up...

" This pre installed script allows you to have the results of forms sent to you by e-mail. The commands used follow broadly the same system as the common Matt`s Formmail script except this version will only send to addresses @rossbowman.info.

Form Action : http://rossbowman.info/cgi-sys/FormMail.cgi

You also need to include a hidden field called "recipient" the value of which is your e-mail address (so the script knows where to send the results to). "

This is the code I`m using for my form...

<form name="mail" method="post" action="http://rossbowman.info/cgi-sys/FormMail.cgi">
<table>
<tr>
<td align="right" valign="top">
<div class="standardtext">Name: </div>
</td>
<td>
<input type="text" name="name" size="20">
</td>
</tr>
<tr>
<td align="right" valign="top">
<div class="standardtext">Email: </div>
</td>
<td>
<input type="text" name="email" size="20">
</td>
</tr>
<tr>
<td align="right" valign="top">
<div class="standardtext">Subject: </div>
</td>
<td>
<input type="text" name="subject" size="20">
</td>
</tr>
<tr>
<td align="right" valign="top">
<div class="standardtext">Message: </div>
</td>
<td>
<textarea name="message" wrap="VIRTUAL" cols="50" rows="6"></textarea>
</td>
</tr>
<tr>
<td>
</td>
<td>
<input type="submit" name="submit" value="send"> <input type="reset" value="reset">
</td>
</tr>

<tr>
<td>
<input type="hidden" name="recipient" value="br[at]ofni.namwobssor">
</td>
</tr>

<tr>
<td>
<input type="hidden" name="required" value="br[at]ofni.namwobssor">
</td>
</tr>

</table>
</form>


And this is the message which I`m getting back when I click submit...

***
There are missing fields
br[at]ofni.namwobssor is missing

Form Dump:
email: gnokgnik[at]ku.oc.namwobssor
message: Will it work this time?
name: KingKong
recipient: br[at]ofni.namwobssor
required: br[at]ofni.namwobssor
subject: Testing Form
submit: send
***


Does anyone have any idea`s???

Go back to General Forum threads, or All Forum threads