Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/13.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
Php 在注册表中使用数组,但未提交表单中的值_Php_Arrays_Forms_Registration - Fatal编程技术网

Php 在注册表中使用数组,但未提交表单中的值

Php 在注册表中使用数组,但未提交表单中的值,php,arrays,forms,registration,Php,Arrays,Forms,Registration,我有一个类似这样的表格: <form class="registration-form" name="applicationForm" action="<?=$_SERVER['PHP_SELF']?>" method="get"> <div class="form-top"><h3 class="col-md-12 col-md-offset-4">Application for employment<

我有一个类似这样的表格:

<form class="registration-form" name="applicationForm" action="<?=$_SERVER['PHP_SELF']?>" method="get">
                    <div class="form-top"><h3 class="col-md-12 col-md-offset-4">Application for employment</h3>  </div> 

                    <div class="col-md-12 col-sm-12 col-lg-6">

                        <div class="col-md-12">
                            <div class="form-group">
                                <label for="inputFirstName">First Name</label>
                                <input type="text" class="form-control required" id="inputFirstName" placeholder="First Name" name="driver[first_name]" />
                            </div>
                            <div class="form-group">
                                <label for="inputMiddle">Middle Initial</label>
                                <input type="text" class="form-control" id="inputMiddle" placeholder="Middle Initial" name="driver[middle]" />
                            </div>
                            <div class="form-group">
                                <label for="inputLastName">Last Name</label>
                                <input type="email" class="form-control required" id="inputLastName" placeholder="Last Name" name="driver[last_name]" />
                            </div>
                            <div class="form-group">
                                <label for="inputDob">Date of Birth</label>
                                <input type="email" class="form-control required datepicker" id="inputDob" placeholder="MM/DD/YYYY" name="driver[dob]" />
                            </div>

您发布的代码中有许多错误

首先,如果您的代码没有结束标记,那么您需要添加它

您也没有为
if(isset($\u GET[“submit”])
设置name属性,例如带有匹配name属性的submit按钮,因此该条件语句中不会触发任何内容

<input type = "submit" name = "submit" value = "Submit">
在循环中:

for ($i = 0; $i < sizeof($_GET['driver']); $i++)
旁注:显示错误只能在暂存中进行,而不能在生产中进行


脚注:

我建议您不要使用GET,而是POST,因为您可能(通过web)发送敏感信息。使用POST更安全

因此,您可以将
$\u GET
的所有实例(包括表单方法)更改为
$\u POST
,您将得到相同的结果

我的回答中的示例结果:

first_name = John middle = Q last_name = Public dob = 01/01/1984 名字=约翰 中间=Q 姓氏=公共 出生日期=1984年1月1日
如果(isset($\u GET[“submit”]){…}
并且您似乎没有结束标记,那么这将永远不会发生。“我有一个类似这样的表格:”-你说“像这样”是什么意思。诸如此类,或者确切地说,“注册后它也不会发送电子邮件。”-我在你发布的代码中没有看到任何邮件功能。那么姓氏和DOB是
电子邮件类型。代码中的错误太多。如果答案解决了问题,请考虑接受答案。下面是如何返回此处并对勾号/复选标记执行相同操作,直到其变为绿色。这会通知社区,找到了解决方案。否则,其他人可能会认为问题仍然悬而未决,并可能希望发布(更多)答案。欢迎来到Stack!非常感谢弗雷德:)我会试试你的建议。@loenex不客气。
for ($i = 0; $i < sizeof($_GET['driver']); $i++)
<?php 
error_reporting(E_ALL);
ini_set('display_errors', 1);

// Then the rest of your code
first_name = John middle = Q last_name = Public dob = 01/01/1984