简体   繁体   English

来自表单的 PHP _POST 数据

[英]PHP _POST Data from Form

I have this form that I'm creating using PHP.我有我使用 PHP 创建的这个表单。 The names of the form elements are a number表单元素的名称是一个数字

<form method="post" action="keywords.php">
    <?php
    echo $question
    ?>
    </div>
    <div class="panel-body">
    <?php
    foreach ($orderexplode as $o) 
    {
        switch ($o) {
            case 0:
                print(" " . "<label>" . $presetwords[$i] . "</label>" . " ");
                $i++;
                break;
            case 1:
                print(" " . "<input type='text' class='form-control' name='$k' id ='$k'placeholder=" . $responsewords[$k] . ">" . " ");
                $k++;
                echo $k;
                break;
        }
    }
    ?>
    <br>
    <button type='submit' class='btn btn-info'>Submit</button>
</form>

How would I go about getting the value of each input box I want to check if it matches $exploded string?我将如何获取要检查的每个输入框的值是否与$exploded字符串匹配?

$string = "Hello How Are You"
$explodedstring = explode(" ",$string)

You are trying to use array indexes.您正在尝试使用数组索引。 You need to use indexes:您需要使用索引:

<?php
foreach ($orderexplode as $k => $o) 
{
    print(" " . "<label>" . $k . "</label>" . " ");
    print(" " . "<input type='text' class='form-control' name='" . $k . "' id ='" . $k . "'placeholder=" . $o . ">" . " ");
}
?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM