0

以下代码不起作用。 forms.phpforms.html是文件名,都保存在根目录中。

错误是“ Undefined variable: POST in C:\wamp\www\forms.php”。我知道我也没有正确处理多个输入。任何人都可以帮助解决这些问题吗?

<html>
<head>
<title>
Registration for Placement
</title> 
</head>


<body>
<h1> Start your Placement process...NOW...</h1>
<form action = "forms.php" method = "POST">
<p> Name <input name = "Name" type = "Text" size = "20" maxlength = "30">
<p> Branch: CSE<input name = "branch" type = "radio" >
            ECE<input name = "branch" type = "radio">
            MEC<input name = "branch" type = "radio">
<p> Languages Known:English<input name ="lang[]" type = "checkbox" value = "1">
                    Hindi<input name = "lang[]" type = "checkbox" value = "2">
                    Tamil<input name = "lang[]" type = "checkbox" value = "3">
<p> State<select name = "state" size = "2">
        <option> Jammu and Kashmir
        <option> Delhi
        <option> Tamil Nadu
        <option> M.P
        <option> U.P
        <option> Maharashtra
        </select>
<p> Thanks for submimitting the form
<p><input type = "Submit" value = "enter" >
    <input type = "Reset" value = "clear"  >


    </form>
</body>

</html>

<html>
<head>
<title>Thank You</title>
</head>
<body>
<h1>Thank You</h1>
<p>Thank you for registering. Here is the information you submitted:</p>

<p>Name </p><p><?php echo  $POST['Name']; ?></p>
<p>Branch </p><p><?php echo $POST["branch"];?></p>
<p>Lang </p><p><?php echo $POST["lang[0]"];?></p>
<p>STATE </p><p><?php echo $POST["state"];?></p>



</body>
</html>
4

4 回答 4

4

代替$POST, 使用$_POST, 更多信息:

http://php.net/manual/en/reserved.variables.post.php

于 2012-06-15T06:33:09.707 回答
3

你应该这样写

$_POST['Name']

$_REQUEST['Name']

于 2012-06-15T06:43:32.327 回答
2

不太了解,但也许“双引号”会造成问题。尝试使用

$_POST['state'];

这可能会奏效。

于 2012-06-15T10:21:58.780 回答
2

$_POST也不$POST应该检查变量是否已定义和设置,您还应该htmlspecialchars()在输出时使用用户输入来避免 XSS 漏洞:

<?php 
echo isset($POST['Name']) ? '<p>'.htmlspecialchars($_POST['Name']).'</p>' : null; 
?>
于 2012-06-15T06:35:16.073 回答