#!D:\Perl\bin\perl.exe use CGI qw(:standard); use CGI::Cookie; |
# editprefsform.pl # # Sample code to display an adjust-movie-preferences form # # This displays a form where the user can pick and choose # what movie categories he would like to subscribe to. # # The reason this is a perl script (instead of a static # page) is that we can check by default the categories the # person is already subscribed to. # |
%cookies = fetch CGI::Cookie; |
if ($cookies{'moviereviewID'} ) { |
# If there is a cookie for this person, then he's
# already made some selections. We grab this info out
# of the database. |
$myID = $cookies{'moviereviewID'} -> value; |
dbmopen(%prefs,"movieuserprefs",0644) || die "Can't
open movieprefs! $!"; |
($propername, @prefs) = split(/~:~/, $prefs{$myID}); |
} else { |
# OK, no cookie available. We could either have
# none of the categories checked, or the default
# ones. Here, I'm going with the default ones. |
@prefs = (1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0); |
$default = 1; |
} |
print header(-'Cache-Control'=>'private'); |
print <<END_of_FormTop;
<HTML>
<HEAD>
<TITLE>Get customized</TITLE>
<META NAME="HandheldFriendly" content="True">
</HEAD>
<BODY>
<p>Please indicate what movies you would like to receive
reviews for:</p>
<form name="choosemovies" action="/cgi-bin/movies/setprefs.pl" >
<p> |
END_of_FormTop |
# We iterate through each category, providing a checkbox # for each. If the user already has this category selected # in his preferences, we add a "checked" to the form. |
@genrenames = ( "Action/Adventure",
"Art House/Indie",
"Classics",
"Comedy",
"Drama",
"Horror and Suspense",
"Kids and Family",
"Musicals",
"Sci-Fi/Fantasy",
"Special Interest",
"TV/Documentary"
); |
for ($i = 0; $i<11; $i++) {
print "<input type=\"checkbox\" name=\"$i\" value=\"1\"";
if ($prefs[$i]) {
print " checked";
}
print ">\n$genrenames[$i]<br>\n";
} |
print "<p>\nPlease enter your first name.\n";
print "<input type=\"text\" name=\"firstname\" size=\"15\"
maxlength=\"15\" value=\"$propername\">\n </p>\n" |
# That's it! Now we just print the rest of the page. |
print <<END_of_Page; |
<input type="submit" name="submit" value="Submit"> |
</form> |
</BODY>
</HTML> |
END_of_Page |
# Copyright (c) 2007, iAnywhere Solutions, Inc., # all rights reserved. # # IANYWHERE MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT # THE SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR # PURPOSE, OR NON-INFRINGEMENT. IANYWHERE SHALL NOT BE # LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT # OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR # ITS DERIVATIVES. |
| Send feedback about this page using email. | Copyright © 2008, iAnywhere Solutions, Inc. |