Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/269.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
I';我试图将我的表单链接到我的PHP页面,我想打印出用户';当他点击提交按钮时,他将输入到该页面上_Php_Html_Forms_Each - Fatal编程技术网

I';我试图将我的表单链接到我的PHP页面,我想打印出用户';当他点击提交按钮时,他将输入到该页面上

I';我试图将我的表单链接到我的PHP页面,我想打印出用户';当他点击提交按钮时,他将输入到该页面上,php,html,forms,each,Php,Html,Forms,Each,我尝试在表单中使用GET方法,在PHP页面中使用$\u GET方法,但它没有将这两个方法链接在一起。我想在用户单击submit按钮时打印出用户输入的表单中的元素。以下是我在表格中使用的代码: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>MY Form</title> </head> <body> &

我尝试在表单中使用GET方法,在PHP页面中使用$\u GET方法,但它没有将这两个方法链接在一起。我想在用户单击submit按钮时打印出用户输入的表单中的元素。以下是我在表格中使用的代码:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>MY Form</title>
</head>
<body>
    <form action="q4.php" method="get">

      <label><b>First Name:</b></label><br />
      <input type="text" name="first_name"><br />
      <label><b>Last Name:</b></label><br />
      <input type="text" name="second_name">

        <br>

        <label for="status">Status</label><br>
        <select name="status" id="status">
        <option value="undergraduate">UnderGraduate</option>
        <option value="postgraduate">Postgraduate</option>
        <option value="alumni">Alumni</option>
        </select>
        <br><br><br>

        <input type="radio" name="continuing">Continuing<br>
        <input type="radio" name="continuing">Not Continuing<br>

        <br><br>
        <label>Satisfaction Level <br></label>
        <label>0</label><input type="range" name="satisfaction" min="0" max="100"/><label>100</label>
        <br><br>
        <input type="submit" value="Submit">
    </form>
</body>
</html>

我的表格
名字:

姓氏:

状态
大学生 研究生 校友


继续
不继续


满意度水平
0100

以下是我在PHP中使用的代码:

<?php
$names = array(first_name => '', second_name => '');

reset($names);
while (list($key, $val) = each($names)) {
    echo "$key => $_GET\n";
}
?>

如果要打印所有结果,可以执行以下操作

<?php
foreach($_GET as $key => $value){
echo $key.": ".$value;
}
?>

但是,如果您希望只显示特定的数据,那么可能是这样的

<?php
$names = array(first_name => '$_GET['first_name']', second_name => 'second_name');

foreach($names as $name => $value){
echo $name.": ".$value;
}
?>

可能想查看更多关于