日期:2012-01-07 浏览次数:20768 次
html显示出来的页面。
提交表单后php处理出来的页面。在这个例子中,我输入一个单词,然后给定一个长度,将单词等分成该长度的块。
演示了通过POST方法提交表单。
例子二(单选,GET接受表单):
<form action="<?php echo $_SERVER["PHP_SELF"] ?>" method="GET">
Select your personality attributes:<br/>
<select name="att[]" >
<option value="perky">perky</option>
<option value="morese">morose</option>
<option value="thinking">thinking</option>
<option value="feeling"> feeling</option>
<option value="thrifty">speed-thrift</option>
<option value="prodigal">shopper</option>
</select>
<br>
<input type ="submit" name="s" value="Record my personality">
</form>
<?php
if (array_key_exists("s",$_GET)){
$des = implode(" ", $_GET["att"]);
echo "You have a $des personality.";
}
?>
例子三(多选,GET接受表单):
注意到此时<select name="att[]" multiple> 下划线告诉GET你传输的是个数组,黑体字部分则是表示改选择框为多选框
<form action="<?php echo $_SERVER["PHP_SELF"] ?>" method="GET">
Select your personality attributes:<br/>
<select name="att[]" multiple>
<option value="perky">perky</option>
<option value="morese">morose</option>
<option value="thinking">thinking</option>
<option value="feeling"> feeling</option>
<option value="thrifty">speed-thrift</option>
<option value="prodigal">shopper</option>
</select>
<br>
<input type ="submit" name="s" value="Record my personality">
</form>
<?php
if (array_key_exists("s",$_GET)){
$des = implode(" ", $_GET["att"]);
echo "You have a $des personality.";
}
?>