CGI Scripting

Using the appendto Script
BASICS

EarthLink's appendto script is used to gather data from a form and then store it on a file on your web site. This is script is suited for those that don't want the data from the form emailed to them but want to retrieve the data from their web site at their convenience.

The Form Page

  1. Create a folder named "data" in the webdocs folder on your webspace.
  2. Create a file named "formresults.txt" inside the data folder.
  3. Set the permissions for the "data" folder to 755
  4. Set the permissions for "formresults.txt" to 646
  5. Create your HTML file with the form on it. Forms can be created using most Web authoring programs. If you don't know how to create forms, refer to the following URLs for creating forms:

    Webcom's Forms Tutorial
    HTML Forms Tutorial by NCSA

  6. Once you've created your form, you will need to set the METHOD of the form to POST and the ACTION of the form to http://home.earthlink.net/cgi-bin/appendto.
  7. You will also need to add the two hidden fields below in between the begin form tag and the end form tag:

    <INPUT TYPE="HIDDEN" NAME="appendfile" VALUE="/data/formresults.txt">
    <INPUT TYPE="HIDDEN" NAME="thankURL" VALUE="
    URL_for_a_thankyou_page">

    where formresults.txt is the name of the file that needs to be created or appended to, and URL_for_a_thankyou_page is the URL of a page (e.g., http://home.earthlink.net/~webmaster/thankyou.html) that you will need to create telling the user that the data from the form has been sent.

    The words appendfile and thankURL are keywords that the script will need. Both keywords are case sensitive. You will get a Server error if the script does not find both of the keywords and if the cases don't match to the one above.

Below is a sample HTML file that uses the appendto script.

<!-- begin sample HTML file using appendto -->

<html>

<head>
<title>Sample Form</title>
</head>

<body>

<h1>Sample Form</h1>

<hr>

<form method="post" action="http://home.earthlink.net/cgi-bin/appendto">
<input type="hidden" name="appendfile" value="/data/formresults.txt">
<input type="hidden" name="thankURL" value="http://home.earthlink.net/~username/thankyou.html">
<p>
<b>Name:</b><input type="text" name="name" size="30"><br>
<b>Email:</b><input type="text" name="email" size="30"><p>
<b>Comments:</b><br>
<textarea name="comments" rows="10" cols="50"></textarea>
<p>
<input type="submit" value="Send">
<input type="reset" value="Clear">
</form>
<p>
<hr>

</body>

</html>

<!-- end sample HTML file using appendto -->

On the above sample form, you will need to replace username with your EarthLink username. Feel free to copy and paste the above example into your favorite text editor and then save it as form.html.

You will also need to create your own confirmation (thank you) page. For your convenience, we have provided a copy and paste sample confirmation page below.

Sample Confirmation Page

The confirmation page is displayed after the visitor has hit the Submit button on your form and the information on your form has been saved. As with the sample above, you may copy and paste from this directly into an HTML file.

<!-- begin sample thank you page -->

<html>

<head>
<title>Thank You!!!</title>
</head>

<body>

<center>

<h1>Thank You!!!</h1>

</center>

<p>
<center>
The information you provided has been sent. We will get back with you as soon as we can.
</center>
<p>

</body>

</html>

<!-- end sample thank you page -->

Feel free to copy and paste the sample thank you page above to your favorite text editor and then save it as thankyou.html.

Other Related Pages

Forms Menu
Sample Form Page
Sample Confirmation Page
Putting It All Together
Frequently Asked Questions



Member Web Support Main Menu