Php 单选按钮仅返回“;关于;提交时

Php 单选按钮仅返回“;关于;提交时,php,post,button,form-submit,radio,Php,Post,Button,Form Submit,Radio,我对PHP非常陌生,我正在尝试以字符串形式显示所选单选按钮的值。但返回的是“开”,而不是与选择相关联的值。任何帮助都会很好 <form action="Handle_form_PHP.php" method="post"> <div class= "row"> <div class ="col-25"> <label for="student">Student</label> </d

我对PHP非常陌生,我正在尝试以字符串形式显示所选单选按钮的值。但返回的是“开”,而不是与选择相关联的值。任何帮助都会很好

<form action="Handle_form_PHP.php" method="post">
    <div class= "row">
      <div class ="col-25">
        <label for="student">Student</label>
      </div>
      <div class ="col-75">
        <input type="radio" name="student" value ="student">
      </div>
    </div>

    <div class= "row">
      <div class ="col-25">
        <label for="student">Employee</label>
      </div>
      <div class ="col-75">
        <input type="radio" name="student" value = "employee">
      </div>
    </div>

    <div class="row">
      <input type="submit" value="Submit">
    </div>
</form>

学生
雇员
这是我用来打印的PHP:

// Create a shorthand for the form data:
$fname = $_REQUEST['firstname'];
$lname = $_REQUEST['lastname'];
$address = $_REQUEST['address'];
$state1 = $_REQUEST['state1'];
$state2 = $_REQUEST['state2'];
$student = $_POST['student'];

// Print the submitted information:
echo "<p>Thank you, <b> $student </b>, <b>$fname $lname</b>, for the filling out our survey:<br>
    <p>We will Send you your report at:  <i>$address</i>, <i>$state1</i><i>$state2</i>.</p>\n";
//为表单数据创建速记:
$fname=$_请求['firstname'];
$lname=$\u请求['lastname'];
$address=$\请求['address'];
$state1=$_请求['state1'];
$state2=$_请求['state2'];
$student=$_POST['student'];
//打印提交的信息:
echo“感谢您,$student,$fname$lname填写我们的调查:
我们将把您的报告发送到:$address、$state1$state2.

\n”;
说出方法时使用POST not POST:

<form action="Handle_form_PHP.php" method="POST">

不是



作为记录,这本书是不正确的,并且有“post”

如果您的
$\u post['student']
超全局变量的值为“on”,那么这个问题与方法的大小写敏感度无关

单选按钮的默认值为“开”,除非在单选按钮标记内提供
属性

让我证明给你看。转到[cringe],然后将以下代码段粘贴到左侧框中,然后运行,然后提交

<!DOCTYPE html>
<html>
<body>

<form action="/action_page.php" method="get">
  <input type="radio" name="student" checked> Student<br>
  <input type="submit" value="Submit">
</form>
</body>
</html>

学生
这是使用
get
的方法提交的(请注意,小写的
get
是无关紧要的。
post
将以同样的方式进行操作)。请注意,如果学生无线电输入中没有
,则提交的值为
on


如果在无线电输入中写入
value=“Red42”
,您将不再在上接收
;提交的值是
Red42

您的表单方法是使用GET还是POST,为什么您只对“学生”使用$u POST?这是POST,我诚实地说,我只是在使用教授给我们的内容,她的代码在所有这些内容中都使用$u请求。我在搜索单选按钮可能有什么问题,然后阅读以使用POST。但这并没有帮助,我只是找到了答案——在30分钟的搜索之后。我把帖子改成了帖子。。。。。。。。。。。。。唉,对不起!方法值大小写敏感度无关。您没有注意到的其他问题。@Red42这个问题解决了吗?
<!DOCTYPE html>
<html>
<body>

<form action="/action_page.php" method="get">
  <input type="radio" name="student" checked> Student<br>
  <input type="submit" value="Submit">
</form>
</body>
</html>