You are here: Re: Sign Up Sheet Needed « HTML « IT news, forums, messages
Re: Sign Up Sheet Needed

Posted by Chris F.A. Johnson on 11/27/43 11:56

On 2006-08-24, Dave Kelly wrote:
> I need some software to create a signup sheet. This is for a fishing
> club and their monthly outings.
> From the administrative side:
> Create the event by name.
> Write a brief description ( 3 - 4 hundred words at most )
> Delete the event.
> From the user side:
> Enter name.
> Enter email address.
> Enter phone number.
> Then display everyone who has signed up for this trip.
>
> Does something like this already exist? Or close enough to use as a
> guide for writing my own?

You need a script to create the form (run it locally and copy the
resulting form to your web site), and a CGI script to parse the
information when it is submitted.

A very rudimentary sample is at
<http://cfaj.freeshell.org/testing/bassline.html>

That form was created by this script:


printf "%s: " "Name of event"
read event
printf "File name for event \"%s\": " "$event"
read filename
filename=${filename%.html}.html
printf "%s: " "File containing description of event"
read desc
description=$( cat < "$desc" )

cat > "$filename" <<EOF
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>$event</title>
<meta http-equiv="Content-type" content="text/html;charset=iso-8859-1">
<meta http-equiv = "Content-Style-Type" content = "text/css">
<link href = "event.css" rel = "stylesheet" type = "text/css">
</head>
<body>
<h1>$event</h1>
<p>$description</p>
<form method="GET" action="list.cgi">
Name: <input type=text size="25" name="name" value=""><br>
E-mail: <input type=text size="25" name="email" value=""><br>
Phone: <input type=text size="25" name="phone" value=""><br>
<input type="hidden" name="event" value="${filename%.html}"
<input type="submit" value="Sign up">
</form>
<p class="validate">Validator:
<a href="http://validator.w3.org/check?uri=referer">HTML</a>
<a href="http://jigsaw.w3.org/css-validator/check/referer">CSS</a>
</p>

</body>
</html>
EOF
#############################################################


And this is the CGI script (Adjust the shebang as necessary):

#! /usr/pkg/bin/bash

main()
{
exec 2>&1
printf "Content-type: text/html\n\n"
parse_query "$QUERY_STRING"
printf "%s\t%s\t%s\n" "$name" "$email" "$phone" >> $event.data

printf "<pre>\n"
cat $event.data
printf "</pre>\n"
}

parse_query()
{
local var val
local IFS='&'

unset name event phone email

set -f
QUERY_ARRAY=( $QUERY_STRING )

for item in "${QUERY_ARRAY[@]}"
do
var=${item%%=*}
val=${item#*=}
val=${val//+/ }

case $var in
event ) event=$val ;;
name ) name=$val ;;
email ) email=$val ;;
phone ) phone=$val ;;
esac
done
}

main
#####################################################

--
Chris F.A. Johnson <http://cfaj.freeshell.org>
===================================================================
Author:
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация