我正在尝试将值从登录页面传递到另一个页面。
从登录页面,成功登录将“用户名”传递回主页:
print redirect("http://example.com/cgi-bin/asg2/Assignment2.plx?x=$login");
主页面接收变量如下:
my $y = param ("x");
并使用以下语句打印:
if ($y){
print "$y";} else {print "Please log in";}
当我第一次被重定向时,$ y被打印出来没有任何问题。但是,当我在主页面中执行表单时:
<form method="POST" action="http://examplecom/cgi-bin/asg2/Assignment2.plx">
<div id="choices">
<h2>Make a Choice</h2>
<input class="css-checkbox" id="Kadinski1" name="Painting" type="radio" value="Autumn in Bavaria -Wassily Kandinsky" /><span id="Kad1">Autumn in Bavaria</span><br />
<input id="Kadinski2" name="Painting" type="radio" value="Movement I - Wassily Kadinsky" /><span id="Kad2">Movement I</span><br />
<input id="Tamara1" name="Painting" type="radio" value="Autoportrait - Tamara De Lempicka" /><span id="Tam1">Autoportrait</span><br />
<input id="Tamara2" name="Painting" type="radio" value="Group of Four Nudes - Tamara De Lempicka" /><span id="Tam2">Group of Four Nudes</span><br />
<input id="Frida1" name="Painting" type="radio" value="Moses - Frida Kahlo" /><span id="Fri1">Moses</span><br />
<input id="Frida2" name="Painting" type="radio" value="What the Water Gave Me - Frida Kahlo" /><span id="Fri2">What the Water Gave Me</span><br />
<input id="Vincent1" name="Painting" type="radio" value="Skull of a Skeleton with a Burning Cigarette - Vincent van Gogh" /><span id="Vin1">Skull of a Skeleton with a Burning Cigarette</span><br />
<input id="Vincent2" name="Painting" type="radio" value="Cafe Terrace on the Place du Forum - Vincent van Gogh" /><span id="Vin2">Cafe Terrace on the Place du Forum</span><br />
<input id="Salvador1" name="Painting" type="radio" value="Swans Reflecting Elephants - Salvador Dali" /><span id="Sal1">Swans Reflecting Elephants</span><br />
<input id="Salvador2" name="Painting" type="radio" value="The Persistence of Memory - Salvador Dali" /><span id="Sal2">The Persistence of Memory</span><br />
<br />
<input type="submit" value="Submit">
<br />
<br />
</div>
</form>
它无法保存$ y的值,无论我做什么,它都会打印“else”语句。请帮忙!
答案 0 :(得分:1)
您还没有向我们展示您的表单,但我猜测您的表单使用默认操作(即页面网址)而没有任何查询参数。