Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I save typed in text, and have the buttons work? 2

Status
Not open for further replies.

Wyldcard9

Programmer
Feb 5, 2004
82
US
Hi,

I am pretty new to HTML. I have a small website I run on my off time, and I also maintain one at work. There really is not much difficult for me to do at either.

I want to set up a form that will allow users to type into a text box some text, and then to click on the submit button and to have that data saved somewhere or emailed off, etc. I also am trying to get the reset button to clear that text box.

The page can be viewed here:

Do I need to add a Database to my site? Do I need to call a PHP page? I really have no idea where to go from here, or what names to look up in tutorials. I went through the <input> section of my HTML book, and that is where I found the submit and reset button code, but nothing about how to make the buttons do anything. I also have Dreamweaver 8.0, but not clear how to make a button do anything. The only button I have is from paypal's code.

Any help pointing me in the right direction is greatly appreciated.
 
Your <Input> elements need to be in a <Form>, then the <Submit> should contain the address of a server-side page which processes the data. Depends on what server-side technologies are available to you, but probably ASP, ASP.NET or PHP

Start by finding what your provider supplies and then have a look at:
who have tutorials for each of the options.

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
At it's most simple you can mail the contents of the form to an email address simply by specifying one in the action attribute of the form tag.

Note the action is in the <form> tag and not in the submit button.
Code:
<form method="post" action="mailto:mymail@mydomain.com?subject=Email%20From%20Website">
	Name: <input type="text" id="name" name="name" value="" />
	<br />
	Email address: <input type="text" id="email" name="email" value="" />
	<br />
	<input type="submit" id="submit" value="submit"/>
</form>

This will use the visitors own mail client to compose and send the mail. However the data will arrive in perhaps not the most readable way (try it, see what happens). This method also leaves you open to spam abuse as your email address is available to all and sundry.

A better way would be to use, as johnwm says a server side script, to collect the data from the form, validate the input, format it and send it via your host's mail server.

There are many free mail scripts out there in every language you can imagine. Just google for them.

You would only need a database if you wanted to store the information that was entered into the form. For email, this is generally not necessary unless you are intent on keeping a log of all emails. Even so, why not keep it locally when the mail arrives at it's destination.


Foamcow Heavy Industries - Web design and ranting
Buy Languedoc wines in the UK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top