除了最后一个CGI中HTML页面的背景颜色外,一切都有效。有人可以帮帮我吗?我很困惑。我不知道为什么背景颜色不会改变。
以下是HTML:
<table border="2" cellspacing="5" cellpadding="5">
<tr>
<td align="center">Name</td>
<td><input type="text" name="customer" size="15"></td>
</tr>
<tr>
<td align="center">Select Membership Type</td>
<td>
<input type="radio" name="membership" value="0">Life
<input type="radio" name="membership" value="1">Annual
<input type="radio" name="membership" value="2">Free Trial
</td>
</tr>
<tr>
<td align="center">Choose Background Color</td>
<td>
<select name="color">
<option value="ye">Yellow
<option value="cy">Cyan
<option value="ma">Magenta
<option value="wh">White
<option value="pi">Pink
<option value="go">Gold
<option value="pa">PapayaWhip
</select>
</td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="Sign Up and Set Options"></td>
</tr>
</table>
</form>
从上面的HTML中保存用户Cookie的CGI:
我将使用数组来保存成员资格类型和哈希值 使用选项标记属性值作为完整颜色名称的键
my $customer = param('customer');
my $chosen_membership = param('membership');
my $color = param('color');
my @membership_type = ("Life", "Annual", "Free Trial");
my %colors = ("ye" => 'Yellow',
"cy" => 'Cyan',
"ma" => 'Magenta',
"wh" => 'White',
"pi" => 'Pink',
"go" => 'Gold',
"pa" => 'Papayawhip');
my $chosen_color = $colors{$color};
my $mycookie1 = cookie(-name=>'membership',
-value=>$membership_type[$chosen_membership],
-path=>'/',
-expires=>'+7d');
my $mycookie2 = cookie(-name=>'customer',
-value=>$customer,
-path=>'/',
-expires=>'+7d');
my $mycookie3 = cookie(-name=>"color",
-value=>$chosen_color,
-path=>'/',
-expires=>'+7d');
print header(-cookie => [$mycookie1, $mycookie2, $mycookie3]);
print start_html ( -title => 'Assignment 7');
print "Thank you. Your data has been recorded</br>";
print "<a href='test3.cgi'>See member page</a>";
print end_html;
阅读Cookie 并使用HTML中的所选颜色作为页面的背景颜色
my $membership_name = cookie("membership");
my $customer_name = cookie("customer");
my $color_name = cookie("color");
print header, start_html;
#what the hell, how to change background color??
<body bgcolor="$color_name">;
print "<h2>Welcome back, $membership_name Member $customer_name.</h2>";
print "<h4>Site rather poor, huh? Sorry. We are working on it.</h4>";
print end_html;
答案 0 :(得分:4)
print
您在这里错过了print "<body bgcolor='$color_name'>";
和一些引用。我很惊讶这一点。
你的意思是:
:- use_module(library(clpb)).
fun(A, B, C, D, E) :-
sat(A + B + C, D),
sat(E),
labeling([A, B, C, D, E]);