PHP表單

<form action=" <?php $PHP_SELF; ?>" method="post"> 
请输入你的名字: 
    <input type="text" name="name"> 
    <br> 
单项选择: 
   <input type="radio" name="first" value ="我很笨">我很笨 
   <input type="radio" name="first" value ="我非常笨">我非常笨 
   <input type="radio" name="first" value ="我简直就是个傻冒"> 我简直就是个傻冒 
    <br> 
多项选择: 
   <input type="checkbox" name="second[]" value ="我喜欢打蓝球">我喜欢打蓝球 
   <input type="checkbox" name="second[]" value ="我喜欢游泳">我喜欢游泳 
   <input type="checkbox" name="second[]" value ="我喜欢跳舞">我喜欢跳舞 
   <input type="checkbox" name="second[]" value ="我喜欢爬山">我喜欢爬山 
    <br> 
   <input type="hidden" name="stage" value = "results"> 
   <input type="submit" value= "submint"> 
</form> 
<?php 
function process_form() 
{ 
$_POST["name"];//错误提示是这样子的:Parse error: syntax error, unexpected '[', expecting ','                    //or ';' in E:\www\web\favrioute.php on line 31 
$_POST["first"]; 
$_POST["second"]; 
$_POST["stage"]; 

if ($_POST["first"] == "我很笨") { $first_message = "你不笨。"; } 
elseif ($_POST["first"] == "我非常笨") { $first_message = "你很聪明。"; } 
else { $first_message = "你简直就象是一个聪明的人了。"; } 

$favorite_second = count($_POST["second"]); 
if ($favorite_second <= 1) 
{$second_message = "但你很快就会在动物园里死去,忏悔吧!";} 
elseif ($favorite_second > 1 && $favorite_second < 4) 
{$second_message = "你是只爱运动的的猩猩。";} 
else {$second_message = "你运动的太多了,对猩猩来讲已经过量,你准备棺材吧!";} 

echo "这是一项针对猩猩的测试: <br>\n"; 
echo "你好! 你的名字叫:$_POST[name]. <br>\n"; 
echo "你的测验结果是......$first_message $second_message <br>\n"; 
} 
?> 

<?php 
if (empty($_POST["stage"])) {display_form();} 
else {process_form();} 
?> 

<?php 
function display_form() { 
global $PHP_SELF;} 
?> 

你可能感兴趣的:(PHP,Web)