Feed-back form

Try online Examples

This will demonstrate how economically a feedback form can be implemented.
If you're trying that script from home, make sure you are connected to the Internet.
See sendMail for configuration details.

Two things worth noting in this eaxmple. One, how we specify and retrieve a multiple selection from a SELECT HTML object. If you are on a PC you can select more than one option by pressing the [Ctrl] key while clicking options. All the selected options will be available in an array in the Aptilis script. Two, the use of join to concatenate (glue together) the values of the array.

Here's what the HTML looks like:

	<FORM action="/cgi-bin/aptilis.exe" method="POST">
	<INPUT type="hidden" name="file" value="/home/scripts/feedback.e.txt">

	Are you a programmer?<BR>
	<INPUT type="radio" name="role" value="(Submitted by a programmer)"> Yes<BR>
	<INPUT type="radio" name="role" value=""> No<BR>
	<BR>
	Which topic(s) would like to be more developped in
	the examples?<BR>
	<SELECT name="topics" size=3 MULTIPLE> (Use [CTRL]+Click to select more than one)
		<OPTION>Real life examples</OPTION>
		<OPTION>Database usage</OPTION>
		<OPTION>Math applications</OPTION>
		<OPTION>Web based forms</OPTION>
		<OPTION>Graphics</OPTION>
	</SELECT>
	<BR>
	<BR>
	Notes:<BR>
	<TEXTAREA name="notes" ROWS=5 COLS=40></TEXTAREA>
	<BR>
	<BR>
	<INPUT type="text" name="email" size=40><BR>
	<BR>
	<INPUT type="submit">
	</FORM>

And now, the Aptilis programme...

sub main

	print("Content-Type: text/html\n\n")

	message = role + "\n\n" $

	n = getarraysize(topics[])
	if n > 0
		message = message + "Topics the sender would like to see more developped:\n" $
	end if

	// Note the use of the join predefined sub that
	// joins together the members of an array.
	message = message + join(topics[], "\n") + "\n" $

	if len(notes$)
		notes = replace(notes$, "\r", "") $
		message = message + "\nNotes:\n-----\n" + notes $
	end if

	print("<HTML><BODY>Your message reads:\n\n<PRE>", message$, "</PRE>\n")
	print("<B>Thank you ", email$,"</B>.\n")

	print("</BODY></HTML>")

	// Remember, this works for me here, but ask your ISP
	// or your system administrator for a valid SMTP server to use.
	setSMTPServer("smtp.ntlworld.com")
	sendmail("teebo@glaine.net", email$, "Aptilis feed-back form", message$)

end main

Things learnt