Forms
Forms are useful for sending and saving user information.
When am I using a form?
How does it work?
1. You lay out form elements in a web page in the HTML:
2. You upload your HTML with the form information in it to your server.
3. You use a form handler---usually a CGI script to do something to the data (saving, helps you search for stuff, gives you a confirmation page or a reciept, etc.)
Another option:
You can send form information easily without CGI to an email address.
How can I make it happen?
The Front End (the
stuff you see on the page)
It is easy to lay out form elements in Dreamweaver. Just select the elements
from the Insert>Form Objects menu (You can choose to insert the form first
(under Insert>Form) , if you don't it will prompt you to do so).
The Back End (the
external script file that processes the data)
Unfortunately this is not as easy as the front end. It requires some knowledge
of CGI scripts (Perl, PHP, JSP, ASP, C or C++, Visual Basic, Applescript, or
Python) and is beyond the scope of this class. These are programming languages.
But, when you are ready, you can learn about CGI through online sample files
and tutorials:
links for cgi (information and scripts to download):
General:
http://www.cgi-resources.com
http://www.icthus.net
Perl:
http://www.cpan.com
http://www.extropia.com
http://www.awsd.com/scripts
PHP:
http://scripts.php-princess.net/
http://br.php.net/sites.php
CGI defined:
As defined by http://www.netlingo.com
Common Gateway Interface
A standard script for running programs on a server from a Web page. CGI programs
(also called scripts) can be run independently and were designed to be external
so they can run under various (possibly different) servers interchangeably.
The most common CGI scripts found on the Web are programs that process the information
a user enters on a form. For example, whenever you fill in information or choose
from a list of radio button options on a Web page, you are most likely filling
out a CGI form. Once you hit the "submit" button, the form is sent
to the server. There, the form's output is handled by a CGI script, which will
call on other programs as necessary (such as a database search engine or a mailer
program). Gateways conforming to this specification can be written in any language
that produces an executable file. Some of the more popular languages that use
CGI include: C or C++, Perl, Python, TCL, shells, and many others.
more info...
CGI scripts send information for each form element through name and value pairs.
ex.
username=Lara
password=fun
"username" and "password" are names for elements (static)
"Lara" and "fun" are values (changing)
CGI scripts retreive all the name and value pairs from an html page and process them.
Security Issues
Some ISP's Internet Service Providers (those who store and serve your site---your server) do not allow CGI scripts because they leave your server open to others who can take your information---hackers.
Your server may not support CGI, if this is the case you can use form hosting
services that you pay for.
*note: for storing scripts on your server, they should go into a folder set up for you called "cgi-bin". Or you may need to make that folder. It's better to store them in the cgi-bin directory because CGI scripts are such potentially large security holes, it's much easier to keep track of what scripts are installed on your system if they're kept in a central location rather than being scattered around among multiple directories. This is where your ISP will assume they are located.
see:
http://www.w3.org/Security/Faq
http://www.w3.org/Security/Faq/wwwsf4.html
If you do use scripts:
1. You will have to copy your scripts to a server with an FTP program,
just as you would an HTML page.
2. You will put them in a folder called: "cgi-bin".
3. When you upload the files, upload them as "ASCII" (text)
and not "binary" files.
4. Permissions: you made need to set permissions for scripts to make
them work for some servers (Unix). You will need to use a program called "chmod".
You can set these with some FTP programs, such as Fetch. Permission ex. read,
write, execute.